Skip to main content

I’m new to Python, and I am trying to get through the oauth token fetch. I am getting this error:


**CustomOAuth2Error** : ({'status': 400, 'reason': 'Bad Request', 'message': 'Illegal client_id', 'code': 'OAUTH_ERROR'}


Here’s my code, just taken from the help doc (redacted my username and secret) -



from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

# Your client credentials
client_id = 'fake user'
client_secret = 'fake password'

# Create a session
client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)

# Get token for the session

token = oauth.fetch_token(token_url='https://services.sentinel-hub.com/oauth/token',
client_secret=client_secret)

# All requests using this session will have an access token automatically added

resp = oauth.get("https://services.sentinel-hub.com/oauth/tokeninfo")
print(resp.content)

Hello,


The Python code is correct and works with my credentials. Did you generate a client id/secret pair in your dashboard, as described in this page? The oauth credentials are what you need to pass as client credentials.


Yup, I created a client id/secret just as it says, and have tried recreating new ones and using those.


Reply