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?