MiBuena
MiBuena

Reputation: 571

ASP.NET MVC OAuth authentication with Jira?

I am building an ASP.NET MVC Application and I need to implement OAuth authentication with Jira.

In Jira Bitbucket repository there is an example of how to configure a client with Java and other languages, but nothing for C#.

Can anyone show me an example for a Jira OAuth Client in C#?

https://bitbucket.org/atlassian_tutorial/atlassian-oauth-examples/src/0c6b54f6fefe996535fb0bdb87ad937e5ffc402d/java/src/main/java/com/atlassian/oauth/client/example/?at=default

https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/

Upvotes: 5

Views: 710

Answers (2)

Jansen
Jansen

Reputation: 139

Probably too late. I came across the internet with the same issue but no luck. So I dug into the code and have such hacky way to achieve what I needed. This is how I did for our project with the Atlassian.NET SDK

var jira = Jira.CreateRestClient(JiraHost);
jira.RestClient.RestSharpClient.Authenticator = new RestSharp.Authenticators.OAuth2AuthorizationRequestHeaderAuthenticator(_JiraToken, "Bearer");
var myself = await jira.Users.GetMyselfAsync();

Basically, the way to use oauth in this sdk is to override RestSharp object for the authentication. This could make the jira object to have enough permission to call the api.

Upvotes: 0

Erik
Erik

Reputation: 51

I have a project using this SDK from atlassian Atlassian.NET SDK in order to get my work a little fast, it has an example of using the authentication

Example of using SDK

var jira = Jira.CreateRestClient("http://<your_jira_server>", "<user>", "<password>");

Upvotes: 1

Related Questions