I am trying to get the data from social bakers API for Facebook but getting an error while requesting it
The error says:
Authorization is not valid.
Here is my code:
import json
import requests
from requests_oauthlib import OAuth1
token = 'mytoken'
headers = { 'Authorization' : 'Token ' + token }
r = requests.get('https://api.socialbakers.com/0/facebook/profiles', headers=headers)
j = json.loads(r.text)
They have given a guide to request their API.
How should I make my request using their format?
2
Answers
Looks like your headers aren’t correct, try running the following code:
hope this helps
Following the documentation example; https://api.socialbakers.com/#security-and-authentication
Using Aladin|OpenSesame as token and secret, first we need to use b64encode on them:
Then in order to have that in the header format of the documentation:
The header should make sense with the one of the documentation, now we are ready to make the request: