git - 如何使用 oAuth token 创建 bitbucket 存储库?

标签 git curl oauth bitbucket

我正在尝试使用curl 和我从bitbucket 收到的oAuth token 创建一堆bitbucket 存储库。我创建存储库的调用如下所示:

curl -X POST -v  -H "Authorization: Bearer 9gcHrIKxN(...)efRXD0-_9T-2qgGNtw"  -H "Content-Type: application/json"  \
  https://api.bitbucket.org/2.0/repositories/FooBarQWD/test_create \
  -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html#repositoryResource-POSTanewrepository

标题解释如下:https://developer.atlassian.com/bitbucket/concepts/oauth2.html

我可以联系服务器,但得到响应

{"error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}

这听起来像是一条合理的错误消息,但如果我传递错误的 token 字符串,我会收到相同的消息。

如果我删除 token 的 header 条目并将其替换为 -u user:password 我可以创建一个新的存储库,因此命令的其余部分应该没问题。

有人可以给我提示吗?

最佳答案

我想我已经明白了。当我从收到的 URL 中复制 token 时,我省略了尾随的“%3D%3D”,它应该是 token 末尾的“==”。如果我附加“==”,则接受 token 并创建存储库。

看来返回的错误信息是错误的。

关于git - 如何使用 oAuth token 创建 bitbucket 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34673883/

相关文章:

ruby-on-rails - Solidus vs Spree - 应该使用哪个?

git - 根据特定条件自动拒绝提交

php - 缺少 Paypal 付款操作

PHP4:通过 cURL 通过 HTTPS/POST 发送 XML?

ruby - 如何使用 Mechanize 单击 Magento 的授权应用程序页面上的 "Authorize"按钮

java - 使用 oauth 保护 Spring Restful Web 服务是一个好方法吗?

Git Blame 查看特定日期后的更改

git - 如何修复 GIT 存储库中的 CRLF 以避免 merge 冲突

php - curl无法下载网页

ios - 如何从登录中获取JSON数据?