How do I handle login authentication using Atlassian.SDK

Deleted user December 2, 2017

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
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.
December 2, 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

Deleted user December 4, 2017

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.

Like David Carr likes this
namilkim February 7, 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 Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events