如何使用 oAuth 令牌创建 bitbucket 存储库?
How can I create bitbucket repos with oAuth token?
我正在尝试使用 curl 和从 bitbucket 收到的 oAuth 令牌创建一堆 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" }'
这里解释Header:https://developer.atlassian.com/bitbucket/concepts/oauth2.html
我可以联系服务器,但得到响应
{"error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}
这听起来像是一条合理的错误消息,但如果我传递错误 token-string,我也会收到相同的消息。
如果我删除令牌的 Header 条目并将其替换为 -u user:password
我可以创建一个新的存储库,这样命令的其余部分应该没问题。
有人可以给我提示吗?
我想我明白了。当我从收到的 URL 中复制令牌时,我省略了尾随的“%3D%3D”,它应该是令牌末尾的“==”。如果我附加“==”,则接受令牌并创建存储库。
所以好像是返回了错误的错误信息。
我正在尝试使用 curl 和从 bitbucket 收到的 oAuth 令牌创建一堆 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" }'
这里解释Header:https://developer.atlassian.com/bitbucket/concepts/oauth2.html
我可以联系服务器,但得到响应
{"error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}
这听起来像是一条合理的错误消息,但如果我传递错误 token-string,我也会收到相同的消息。
如果我删除令牌的 Header 条目并将其替换为 -u user:password
我可以创建一个新的存储库,这样命令的其余部分应该没问题。
有人可以给我提示吗?
我想我明白了。当我从收到的 URL 中复制令牌时,我省略了尾随的“%3D%3D”,它应该是令牌末尾的“==”。如果我附加“==”,则接受令牌并创建存储库。
所以好像是返回了错误的错误信息。