I’m trying to get a token using python and authenticating via OAuth2 with the “Authorization code + Implicit Grant Type” check box checked. My code is as follows:
client_id = r'iClient ID]'
client_secret = r'eClient Secret]'
auth_url = "https://tOurDomain]/oauth2/authorize"
redirect_uri = "https://tOurDomain]"
token_url = "https://tOurDomain]/oauth2/token"
oauth = requests_oauthlib.OAuth2Session(client_id, redirect_uri=redirect_uri)
# Redirect user to Docebo for authorization
authorization_url, state = oauth.authorization_url(auth_url)
print('Please go here and authorize: ', authorization_url)
authorization_response = input('Enter the full callback URL')
token = oauth.fetch_token(
token_url,
#authorization_response=authorization_response,
code=authorization_response,
client_secret=client_secret)
I seem to successfully make my way to the portion where I get the token. I do feel like I’m unsure of the callback URL I should be passing in for code. I’ve tried several variations of the authorization_url and all result in the following error:
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Authorization code doesn't exist or is invalid for the client