How do I handle login authentication using Atlassian.SDK

I'm writing my own Visual Studio startpage for personal use, and want to embed my open Jira tickets there using the Atlassian SDK nuget package. However, I'm setting it up as a more generalized project, so I can share it with interested colleagues. This means that the username and password used to connect are given by the user on first use and may not be correct. On incorrect logins, I want to give the user the ability to change the given username or password, but to do this I need to know that that was the actual problem in the first place.

Tests show me that giving an incorrect username or password throws an Exception with message "The request was aborted: The connection was closed unexpectedly.". How can I check if this was a problem with authentication or some other issue?

I've noticed that, when there's no internet connection available, the exception's message is "The remote name could not be resolved: 'mycompany.atlassian.net'". So I could filter those out to be a bit more sure, but this doesn't look like a good solution to me.

I'm using this code to fetch my issues:

var jira = Jira.CreateRestClient("https://mycompany.atlassian.net", $"{_username}@mycompany.com", _password);
var issuesForUser = jira.Issues.Queryable.Where(issue => issue.Assignee == _username).ToList();

Any help is greatly appreciated.

1 answer

0 votes

Hello,

I am not sure about the library which you are using but maybe you could make a call to auth/1/session. I think you can get a more meaningful exception from this REST API call. You can read more about auth/1/session here:

https://docs.atlassian.com/jira/REST/cloud/#auth/1/session

Thanks for the fast response! I (wrongly) assumed that the nuget package was an official Atlassian one. After checking out the source, I can see that it actually uses the .NET rest client to make normal rest calls (and does so poorly). The link you've provided is a lot more useful. Thanks again.

Hi,  

I am call http://myserver.co.kr/rest/auth/1/session

but server only return 404 not found error

 

hot to fix it?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

629 views 1 15
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you