Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Facing problem while authentication with Rest Api using node js

ABHAY D DESHMUKH
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 15, 2019

Hi ,

I am using

 https://mydomain.atlassian.net/rest/api/2/search?jql=project = 'project' AND issuetype = 'story'

query to retrieve data from JIRA.

My node js code :

const requestObj = {

headers: { 'content-type': 'application/json' },

url: "https://mydomain.atlassian.net/rest/api/2/search?jql=project = 'myproject' AND component = 'mycomponeny' and issuetype = 'story'",

auth: { Basic: ('myid@project.com:vtrhtututitittitfterew').toString('base64') },


 Accept: 'application/json'

};

I am getting error "auth mechanism is not defined"

I have also tried 

auth: { bearer: ('myid@mydomain.atlassian.net:vtrhtututitittitfterew').toString('base64') },

 auth: { Basic: ('myid@mydomain.atlassian.net:vtrhtututitittitfterew').toString('base64') },

 

But I am still getting error "auth mechanism is not defined"

your help is highly appreciated.

Regards,

Abhay

 

1 answer

1 accepted

0 votes
Answer accepted
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2019

Hi @ABHAY D DESHMUKH 

I use C# as opposed to js, but the differences that I notice are :

  • I use Authorization and you seem to use auth
  • I use Basic, so stick with that one
  • The format looks like 
    Authorization: Basic vkd2FycmVuLmxld

Hopefully you can get something out of this to help you

ABHAY D DESHMUKH
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 17, 2019

Thanks Warren 
The format I have used is mentioned in Jira rest api documentation.
I have tried with Authorization and basic and it work properly.

Regards,

Abhay

CrazyAs5assin May 13, 2020

Hi can you let me know what was the Authorization header you used . I tried but it's not going through

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2020

Hi @CrazyAs5assin 

So my header looks like

Authorization: Basic encodedDetails

where encodedDetails is the 64 bit encoded combination of the Jira e-mail address and the API key.

If this doesn't help you, you'll need to give more info about what you're trying to do, what you've done and what problem you're facing.

Suggest an answer

Log in or Sign up to answer