Reputation: 154
When I try to submit my form from python flask to linkedin I get the following exception: {"error_description":"the client is not authorized","error":"unauthorized_client"} I've checked the code and everything should be working.
post = {
"grant_type": "authorization_code",
"code": code,
"redirect_uri": os.environ["REDIRECT_URI"],
"client_id": os.environ["API_KEY"],
"client_secret": os.environ["API_SECRET"]
}
access = requests.post("https://www.linkedin.com/uas/oauth2/accessToken", data=post)
return access.text + str(post)
All of my environment variables appear to be correct. (I've checked multiple times) but I'm still getting the same error. I have already registered the app on linkedin as well and have been strictly following the documentation. Anybody know what I might be doing wrong?
Upvotes: 0
Views: 939
Reputation: 154
The problem wasn't with the access codes but with the REDIRECT_URI. I had it previously encoded for the get request so that it'd be in the proper formula for that. However that format doesn't work the same for a POST request. Rather than https%3A%2F%2Fwww.example.com%2Flinkedin it needs to be formatted https://www.example.com/linkedin. This is because the request library will escape the parameters, and if it's already escaped it will become double-escaped.
Upvotes: 1