Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to specify custom callback url on authorization

Ruan Robson March 18, 2022

I am trying to implement OAuth2. I have followed this guide:

https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/

It says that I can include the callback url per request, but I cannot seem to find what the parameter is called to allow me to do this. Can you please point me to some documentation that can clear up how to specify a different callback url, as I cannot find any

2 answers

1 accepted

0 votes
Answer accepted
Ruan Robson March 18, 2022

The property name is redirect_uri

Andy Fletcher May 29, 2022

Hi @Ruan Robson ,

Did you manage to get this to work? I've set my callback url in the OAuth consumer to http://localhost:8080/callback but whenever I try to auth with 

https://bitbucket.org/site/oauth2/authorize?client_id=xxx&response_type=code&redirect_uri=http://localhost:8080/callback/foo then in the callback, when requesting the access token, I get an error 'redirect_uri does not match'.
In fact it still fails if I set the redirect_uri parameter to exactly what I've configured in the consumer.
Many thanks,
Andy
Ruan Robson May 29, 2022

Hi Andy,

 

My setup is as follows:

 

Button with url:

Then in my code (That gets executed on callback/foo) I have a http request with the following details:


Request Payload:
{
"grant_type": "authorization_code",
"code": "code from query string",
}
Headers:
'Content-Type': 'application/x-www-form-urlencoded'
Auth for this call uses the client id and secret.

I hope this info helps.
Andy Fletcher May 30, 2022

Aaaah, thank you so much!

The `redirect_uri` parameter needs to be on both the request for the code and the request for the token! I thought the error was about it not matching the url stored against the consumer in the workspace settings.

Strange that the documentation is so sparse here. I'd read the same page that you'd originally linked to which said you should be able to append to the callback url path but gave no indication how.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events