Hello. I am trying to create a new, empty, private repository in my bitbucket.org account via the command line (shell, whatever) using `curl`.
I think there are certain steps that I need to take but I don't understand what they are, that is to say, I think I'm missing something, despite trying to Google my way out of this.
So I'm going to show what I've tried, and see if maybe someone who knows more than I do can point out what I am doing wrong.
n.b - My BitBucket account has 2-Step/2-Factor turned on, so I created an “App password” with the ability to read/write/admin repositories.
I've replaced my app password with 'XXXXXXXXXXXXXXXX' but otherwise everything is exactly how I entered it
curl -i -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {XXXXXXXXXXXXXXXX}" \
-d '{
"scm": "git",
"is_private": true,
}' "https://api.bitbucket.org/2.0/repositories/{tjluoma}/{new-test-repo}"
Result: I get this message back:
{"type": "error", "error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}
I'm not sure what an access token or a refresh token is, exactly, but I've tried various things, and none of them have worked:
curl -X POST -u "tjluoma: XXXXXXXXXXXXXXXX" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials
Result:
{"error_description": "Invalid OAuth client credentials", "error": "unauthorized_client"}
So how do I authorize… curl?
Next I tried this:
curl -S --location --fail -u "tjluoma: XXXXXXXXXXXXXXXX" "https://bitbucket.org/site/oauth2/authorize?client_id={tjluoma}&response_type=code"
but that just gave me this:
Result: curl: (22) The requested URL returned error: 401
So I'm rather stuck and feeling stupid. If anyone would be willing to offer some advice, I'd be most appreciative. Thanks for your time
Note: I finally figured it out. I was trying to use OAuth when I didn't need to be, because I had created an app password.
You can see my working script at https://bitbucket.org/tjluoma/new-dual-repo/src
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know if there are any other ways to do it… there may well be… but this is an easy way that worked the way that I was trying to get it to work. FWIW.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.