我正在尝试使用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://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/