0

I am trying to connect to the BitBucket API using OAuth-2 and using a OAuth2 client script.

I get to the redirect page where its says "Confirm access to your account" and I click on "Grant access" in which it redirects me back to my callback url. But I get an error messaged saying "unauthorized client" with the description:

Client credentials missing; this request needs to be authenticated with the OAuth client id and secret

I am providing the client id and client secret so I'm not sure where the problem is. I've searched on this topic for a while now but the information is limited.

Any help would be appreciated.

2 Answers 2

1

I have solved this by using the curl command line I found in the BitBucket documentation:

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

The answer I found from searching around is that the client_id and secret are seen as the username and password. This at first was not obvious to me. Using an OAuth client script does not seem to work with BitBucket's version of OAuth2. But using OAuth 1 with BitBucket works without any issues.

I hope this helps anyone having similar issues.

Sign up to request clarification or add additional context in comments.

Comments

0

You can try this URL $ curl -X POST -u "client_id:secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=password -d username={username} -d password={password}

/// this is API exposed by bitbucket

where client_id : your client id (eg: 75frt****) secret : your secret key (eg:8uyrioooreu*****)

username : password :

so above URL will be updated as $ curl -X POST -u "abc*******:123****" https://bitbucket.org/site/oauth2/access_token -d grant_type=password -d username={[email protected]} -d password={******}

Note: Initially I was using alias username in 'username' field and I was facing error "Unauthorised client" error, later when I changed username to my registered email id [[email protected]], it worked fine.

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.