While I can find many examples and tutorials to auth using basic auth against JIRA, the recent cloud versions seem to only support OAUTH 2 and I have not found a code example that works against our cloud version. Can anybody provide information to the method and practices?#1 Is the general idea that you auth and retrieve a token, and then pass that token to the API calls?#2 Can you provide a working .NET example / article?PS: the official BitBucket examples do not contain anything for .NEThttps://bitbucket.org/atlassianlabs/atlassian-oauth-examples/src/master/
Hi Travis,
I see that you're using .NET/C# and are interested in creating an app that will integrate with Jira Cloud. I have not been able to locate a clear example code that shows how to make this exact connection, even when finding a similar thread in our developer community. However I did come across a project in which someone seems to have created an SDK for .NET, check out https://bitbucket.org/farmas/atlassian.net-sdk/src/master/README.md
While this was originally created for Jira Server, this could be adopted with some changes for Jira Cloud. That post gives some steps you can take to get started over in https://bitbucket.org/farmas/atlassian.net-sdk/src/e51934c33c796ba9b4c83bac75f740ed4d04bc2f/docs/how-to-use-the-sdk.md
One thing that would need to be changed is how the authorizations is happening, for example that page shows the call using a password:
// create a connection to JIRA using the Rest client var jira = Jira.CreateRestClient("http://<your_jira_server>", "<user>", "<password>");
However Jira Cloud won't allow you to use basic auth with a password today, that functionality was deprecated a few years back. You could create an API Token first, and then follow the steps over in Basic Auth for REST APIs. Essentially, in order to use basic auth, you need to create a string that includes that users email address and API token in the format of
user@example.com:APItoken
and then base64 encode that string. With the encoded string, you can pass that in an authorization header when making any REST call and this will act on behalf of that specific user.
Basic auth is easier to setup and get working, but it's not as secure as OAuth is. Atlassian does recommend using OAuth when creating your own apps to interact with Jira Cloud because the security is so much better.
The process of using OAuth is more complex to setup though. This is detailed over in https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/ This guide just provides an overview of what has to happen to make this work, it does not provide specific programming language examples.
With an OAuth 2.0 setup, there is a handshake that has to happen between your app and our Authorization server. This can then generate for you a different kind of ACCESS_TOKEN. These work differently from the Basic Auth API Tokens that any end user can create. But once your app has this access token, your program will then have to also create a header and pass that token to make the API call. But the formatting of that header is different than a basic auth header, and also this does not include an email address or base64 encoding like basic auth does.
I'd suggest trying to setup with that SDK and the basic auth first to start.
Andy
It looks like you're new here. Sign in or register to get started.