bash - Check Bitbucket credentials by OAuth 2.0 keys -


i've created oauth key inside bitbucket , want replace current shell/bash function check if username , password correct. function returned http response code.

how can bitbucket oauth keys? i've tried replace $username , $password keys doesn't work.

  http_status=$(curl -x head -s -w '%{http_code}' \   -u "$username:$password" -h "content-type: application/json" \   https://api.bitbucket.org/2.0/repositories/$repo_owner) 

you should able use authorization header instead of -u parameter:

http_status=$(curl -x head -s -w '%{http_code}' \     -h "authorization: bearer <oauth_token_goes_here>" \     -h "content-type: application/json" \     https://api.bitbucket.org/2.0/repositories/$repo_owner) 

if don't have token yet you'll have request one, e.g.

request authorization end user sending browser to:

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

the callback includes ?code={} query parameter can swap access token:

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

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -