gpt4 book ai didi

bitbucket - 如何获取bitbucket的refresh_token?

转载 作者:行者123 更新时间:2023-12-05 08:54:37 30 4
gpt4 key购买 nike

我正在使用下面的 API

https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=token

获取 access_token 但 access_token 在 1 小时后过期,我需要 refresh_token 但我无法在上述 API 的响应中获取 refresh_token。以上API的响应是

https://www.example.com/#access_token={access_token}&scopes={scopes}&expires_in=3600&token_type=bearer

你可以看到上面的响应中没有或者有没有其他方式获取refresh_token。

我想调用上面的 API 作为 GET 方法。

可以请人帮忙。

谢谢!

最佳答案

在您的浏览器中转到

https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code

使用您的 bitbucket 帐户授权。

之后,您的浏览器将被重定向到

{your_redirect_link}/?code={code}

使用代码在终端中发出另一个请求:

curl -X POST -u "{client_id:secret}"https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}

响应看起来像这样:

{
"access_token": "some_long_string",
"scopes": "team webhook account issue wiki pipeline pullrequest project snippet",
"expires_in": 7200,
"refresh_token": "the_string_you_need",
"token_type": "bearer"
}

现在你可以通过请求刷新access_token

curl -X POST -u "{client_id}:{secret}"https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={refresh_token}

关于bitbucket - 如何获取bitbucket的refresh_token?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49168752/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com