Bing Advertising API Request Access_token via Authorization_Code, returning format error

zhiliao wu 0 信誉分
2024-05-14T08:20:27.5266667+00:00

Trace ID: BD1AD058-ED6B-4AE6-B885-09C268207400
use the requests.post to get token through Authorization_Code verification method;

url = f"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token"
body ={
"grant_type":"authorization_code"
,"client_id": app_id
,"scope":"https%3A%2F%2Fads.microsoft.com%2Fmsads.manage"
,"code":code
,"redirect_uri":redirect_url
,"client_secret": client_secret
}
headres = {"Content-Type": "application/x-www-form-urlencoded"}
r=requests.post(url,data = body,headers=headres)

Return to the wrong: {'error': 'invalid_grant', 'error_descript': 'Aadsts9002313: Invalid Request. Request is Malformed or Invalid}
What form should I use to get token? Thanks

Microsoft Graph
Microsoft Graph
一种 Microsoft 可编程性模型,用于公开 REST API 和客户端库以访问 Microsoft 365 服务上的数据。
25 个问题
0 个注释 无注释
{count} 票