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
Alexey Matveev Community Champion Dec 02, 2017

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.

namilkim I'm New Here Feb 07, 2018

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot