Reputation: 571
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://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/
Upvotes: 5
Views: 710
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
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
var jira = Jira.CreateRestClient("http://<your_jira_server>", "<user>", "<password>");
Upvotes: 1