我在我的Django项目中使用django-oauth-toolkit 0.7通过我的网站提供Oauth2。
我已经按照步骤here成功获取了访问令牌,但无法使用refresh token获取新的access token(如果访问令牌已过期)。
我可以使用consumer client获取access token,但是如何使用我网站中的url获取该url,因为当我尝试使用refresh token获取新的access token时,我无法看到我的站点的参数是什么。
我的访问和刷新令牌如下所示:
{
"access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in":3920,
"token_type":"Bearer",
"refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
}任何帮助都将不胜感激。
发布于 2015-01-03 10:37:27
要获取新的access_token,通过使用现有的refresh_token,您需要将POST请求发送到最初用于获取令牌的同一个url (/o/token/,假设为默认url)。grant_type现在将是refresh_token,您还需要使用您的客户端凭据进行身份验证,因为您已经获得了一些凭据。
总结一下:curl -X POST -d "grant_type=refresh_token&client_id=<your_client_id>&client_secret=<your_client_secret>&refresh_token=<your_refresh_token>" http://localhost:8000/o/token/
如果您想了解更多信息,可以查看此link以查看该标准的相关部分。
发布于 2018-10-16 14:33:03
您可以在POSTMAN中传递post请求。或者试试这个,它对我很有效:
curl -X POST -H 'Authorization: Basic your_application_id' -d 'refresh_token=your_refresh_token&grant_type=refresh_token' localhost:3000/o/token
{
"token_type":"bearer",
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiVlx1MDAxNcKbwoNUwoonbFPCu8KhwrYiLCJpYXQiOjE0NDQyNjI4NjYsImV4cCI6MTQ0NDI2Mjg4Nn0.Dww7TC-d0teDAgsmKHw7bhF2THNichsE6rVJq9xu_2s",
"expires_in":20,
"refresh_token":"7fd15938c823cf58e78019bea2af142f9449696a"
}尝试此Link
发布于 2021-10-05 06:32:15
要通过URL从refresh_token获取新的access_token,您可以使用以下URL并在参数中传递数据:
http://127.0.0.1:8000/o/token/?grant_type=refresh_token&refresh_token=<refresh_token_here>&client_id=<your client id here>&client_secret=<your client secret here>一旦你在refresh_token的帮助下生成了一个新的access_token,那么旧的access_token就会过期。
https://stackoverflow.com/questions/26903087
复制相似问题