尝试从Linkedin获取访问令牌时,得到的响应为:
'{"error":"invalid_request","error_description":"A required parameter \\"client_id\\" is missing"}'
下面是我的代码。我正在按照文档页面中的建议在正文中传递客户端ID: https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/consumer/context
def linkedin_login_callback(request):
url = 'https://www.linkedin.com/oauth/v2/accessToken'
headers = {"Content-Type" : "application/x-www-form-urlencoded"}
data = {"code" : request.GET['code'],
"client_id" : '<client_id>',
"client_secret" : '<client_secret>',
"redirect_url" : 'https://127.0.0.1:8000/users/accounts/linkedin_login/login/callback/',
"grant_type" : 'authorization_code',
}
data = json.dumps(data)
resp = requests.post(url, headers=headers, data=data)
print(resp.content)
#IGNORE FROM HERE. I am currently redirecting in order to avoid error.
return redirect('fsc-home')
预先感谢您的帮助。