Quantcast
Viewing all articles
Browse latest Browse all 14155

I can't use the blogger api it gives me a 403 error even though i am authorized

This is my code that is supposed to get an access token using a service account I have set up (which is done correctly) then use the access token to authorized an API request to the blogger API (which isn't done correctly for some reason) to make a blogger post:

from google.oauth2 import service_accountimport google.auth.transport.requestscreds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)request = google.auth.transport.requests.Request()creds.refresh(request)access_token = creds.tokenprint(access_token)print("access token granted")headers = {'Authorization': f'Bearer {access_token}','Accept': 'application/json',}response = requests.post(f'https://blogger.googleapis.com/v3/blogs/6084243137377471911/posts?access_token=%7Baccess_token%7D&key=%7Bblogger_api_key%7D',headers=headers,json=data,)print(response.text)

gives a super long access token along with the access token granted thing + this:

"error": {"code": 403,"message": "We're sorry, but you don't have permission to access this resource.","errors": \[{"message": "We're sorry, but you don't have permission to access this resource.","domain": "global","reason": "forbidden"}\]}}

I just copied most of it and I expected a 200 OK response with the json data of the post but all I got is that 403 error


Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>