1

I want to manage my blogger blog with Python. In Google Cloud Console I created a service account. I assigned it the rols owner and editor. The user that owns the project is the same google account that created my blog. I would expect my service account to have permission to read and publish in all my blogs. But I cannot even get a list of all my blogs.

from google.oauth2service_account import Credentials
from googleapiclient.discovery import build

SERVICE_ACCOUNT = ... # Path to service_account.json
scopes = ['https://www.googleapis.com/auth/blogger']
creds = Credentials.from_service_account_file(
            SERVICE_ACCOUNT, scopes=scopes)
service = build('blogger', 'v3', credentials=creds)
user_blogs = service.blogs().listByUser(userId='self').execute()

In user_blogs I get {'kind': 'blogger#blogList'}, without 'items' in it. I understand this means it is not asking for the blogs of the project's user. Furthermore, if I change the request and write listByUser(userId=<my-gmail-id>), an HttpError raises saying:

"We're sorry, but users can only access their own user-specific information."

How should I use my service account? Should I change its permissions?

3
  • When you use a service account, the identity is the service account email address. There is no matching of a service account's identity to your Google Accounts identity. They are separate identities. Mar 27 at 1:57
  • And I can't give the author privilege to the service account as I could invite any normal email account?
    – Jorge Luis
    Mar 27 at 6:34
  • Are you asking a question or stating something? I am not sure about the blogger API. That API is not part of Google Cloud. Based on the documentation, only User OAuth is supported. Sometimes, you can add a service account email address to a Google service, for example Gmail, as an authorized user. Try that and report back. Mar 27 at 6:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.