How to Access the Verification Code When Requesting Access Token

Martin Lyubenov March 19, 2019

Hello guys,

I am building application, that will have the feature to access Jira's database and create issues in Jira as well. I followed this guide:, however there are some thing unclear to me...

I am able to get the request token, but how do I extract the Verification code? 

In the guide it is said to copy it from the web page, I am redirected to after I give permission. Is there any way to extract this code? 

Thanks a lot!

 

2 answers

1 accepted

1 vote
Answer accepted
Martin Lyubenov March 25, 2019

For anyone who is having the same issue as I did - here is how you could get around it:

Notice that when you click ALLOW, then you are redirected to a window and in its url you have the request token and the verification secret, then I used HostListener to get the info from the url and pass it to the access token request

@HostListener('window:message', ['$event']) onMessage(event) {
this.authService.authorizeWithJira(event.data.value.token, event.data.value.secret)
.subscribe((data: string) => {
localStorage.setItem('token', data);
this.syncWithJira();
});
}

Note: authoriseWithJira is a method in the authService, that send request for the access token.

Note: Jira has CORS disabled and you might need to do this on the backend.

0 votes
Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 22, 2019

Hi Martin and welcome to Atlassian Community!

As per I could understand on the guide, after you request the token and go to the URL that appears on the terminal, you will see the option to Allow or Deny. Clicking on Allow will show an output on your browser with the verification code:

Access Approved
You have successfully authorized 'Example JIRA app'. Your verification code is 'qTJkPi'. You will need to
enter this exact text when prompted. You should write this value down before closing the browser window.

Are you facing some issue after clicking on "Allow"?
Have you tested using another browser just to make sure that there is nothing blocking this output to be generated?

Regards,
Angélica

Martin Lyubenov March 25, 2019

Hi, Angelica, thank you for your help.

The problem was that the guide I was following was made so the verification code is shown in a browser window, after you click ALLOW, then you have to copy it and send it in order to receive an access token. Which was obviously not what I wanted.

I will post a separate answer to explain how I managed to get around this if anyone has the same problem in the future.

Thanks for the time.

Like Angélica Luz likes this
Prashanth Mp January 6, 2021

Hi Martin, After clicking on Allow, does the response have the verification code? I checked the browser's network tab and do not see any response. I just see the following message in the browser. 

Access Approved

You have successfully authorized 'elite'. Please close this browser window and click continue in the client.

 

This is a windows desktop app.

Suggest an answer

Log in or Sign up to answer