Hi. New Here.
I am integrating Jira with a .Net Core MVC application (C#) with OAuth 2. I go through the redirect to atlassian.com to get permission from the user, and then exchanging the returned code for an access token. That all works fine.
When I attempt to make any request to the API with the just returned Access Token, I always get a 401 (Unauthorized) response.
I’m just running a POC at this time, so I chose to simply call “myself”. The scopes setup for my app are manage:jira-data-provider, read:jira-work, write:jira-work, read:jira-user, but I don’t think that matters at this point since this is an authentication issue, not a permissions issue (I think).
Here’s the code that makes the get request with the HttpClient object.
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Bearer”, jiraToken.access_token);
httpClient.DefaultRequestHeaders.Add(HttpRequestHeader.Accept.ToString(), “application/json”);
var response = await httpClient.GetAsync(new Uri(“https://MyDomain.atlassian.net/rest/api/3/myself”));
By the way, I also tried “Basic” in the authentication header since I saw that in some articles, but seems to me that this is a Bearer token that I’m using.
Is there additional header information I need to pass? Anyone have some insight into how I can get past this early speed bump?
Thanks.