This is a bug I believe, and it took me 2-3 days to figure it out. Please do the following to get it...

本文解决了一个关于OAuth2访问令牌获取的问题,通过调整URL、请求头和POST数据等步骤,成功解决了开发者遇到的难题,并提供了快速获取访问令牌的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This is a bug I believe, and it took me 2-3 days to figure it out. Please do the following to get it working,

1) Remove the "?api-version=1.0" from your URL. I know it sounds strange but trust me their documentation is a mess.

2) Add a "Content-Type": "application/x-www-form-urlencoded" header in your request (hence you'll have to encode the post data values ... for example redirect_url=(encodedURL) etc

3) Remove unnecessary fields from post data REFER ... it should be like

{
    'grant_type': "authorization_code",
    'resource': "your resource",
    'client_id': "your client Id",
    'redirect_uri': "your redirect URL",
    'client_secret': "your client secret",
    'code': "the code u got"
}

 

I see you have done point 2 so you'll need to do point 1 and you're good to go.

Furthermore, if you want to get access_token quickly(if nothing I said works for you), then pass "client_credentials" in grant_type and you'll get a smaller response with access_token. But if you want the complete response with refresh_token as well, you'll have to do all those steps.

EDIT: There is one more mistake in their documentation, for Refresh Tokens >>> the URL should be oauth2/token and NOT oauth2/authorize

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值