gioboa / jira-plugin

Jira plugin for VsCode
https://marketplace.visualstudio.com/items?itemName=gioboa.jira-plugin
MIT License
265 stars 41 forks source link

deprecation of /rest/api/2/project + deprecation of basic authentication with passwords for Jira #123

Closed kpolivier closed 5 years ago

kpolivier commented 5 years ago

Describe the issue Can't connect to atlassian anymore... They seem to have change securities for authentification in june: https://confluence.atlassian.com/cloud/deprecation-of-basic-authentication-with-passwords-for-jira-and-confluence-apis-972355348.html I have been able to set up the plugin to connect but no way to select a working project in the status bar, it's empty and no error in the log...

To Reproduce Try to set the plugin with an atlassian account with basic authentication, & 301 (authorization failed) will occured. When creating a JsonWebToken in the atlassian account and set up the plugin again, connection seems to be ok but no working project available... Jira-plugin version is 0.18.2

gioboa commented 5 years ago

Hi @kpolivier, try to create a token form your Jira Web Application and use this token in the plugin password field. 👍

kpolivier commented 5 years ago

yes, that's what I did. Otherwise I had been unable to connect...

gioboa commented 5 years ago

Sorry, I did not catch the info. 👍 Follow these steps please:

Did you see any json data?

kpolivier commented 5 years ago

Yes, on Chrome I can connect to Atlassian and get the JSon with the URL you gave me. But when trying to select a project in VSCode I got the message 'Set working project' in the upper bar and no project to select... Capture

gioboa commented 5 years ago

The fastest way to hack the code and understand what's append is open this file: on macOS / Linux ~/.vscode/extensions/gioboa.jira-plugin-0.18.2/out/src/services/store.service,js on Windows: %USERPROFILE%.vscode\gioboa.jira-plugin-0.18.2\out\src\services\store.service,js and at line 46 insert this code:

console.log('JIRA projects', yield this.state.jira.getProjects());

Save the file and restart VsCode Now if you open VsCode Developer Tools you can see the console.log with all projects retrieved by the HXR call.

kpolivier commented 5 years ago

Here is what I got:

[Extension Host] JIRA projects Array(0) length: 0 __proto__: Array(0)

kpolivier commented 5 years ago

If I try to connect with this command, I got an empty array, so I suppose the problem is from Atlassian, not the plugin: curl -v https://{mysite}.atlassian.net/rest/api/2/project --user {myusertoken}={myuserPassword}

I will check if everything is ok on my account...

kpolivier commented 5 years ago

I tried to delete my token and generate it again but no more luck...

In the documentation, I found /rest/api/2/project was deprecated and now we should use instead /rest/api/3/project/search but even with this URL, I got an empty array... Ar you able to get something on your side?

gioboa commented 5 years ago

Yes, I can modify the code for use the new endpoint. If you try with curl this one /rest/api/3/project/search?jql=&maxResults=200 you get some results?

kpolivier commented 5 years ago

ok, that's all fine now... I get the project... thank you!

gioboa commented 5 years ago

Did I miss something? 😕 Is it working?

kpolivier commented 5 years ago

yes, it's working now. Be sure to use the new URL /rest/api/3/project

gioboa commented 5 years ago

So I will modify the pulgin to call /rest/api/2/project and if there aren't projects /rest/api/3/project. ok?

kpolivier commented 5 years ago

As it seems rest/api/2 is being deprecated, I would have done the opposite but anyway, it should work...

But I don't know why rest/api/2 call give me an empty array whereas rest/api/3 send me the full list... I suppose some bug in the atlassian API...

gioboa commented 5 years ago

@MrRefactoring do you think we can include the version option in jira-connector getAllProject call?

MrRefactoring commented 5 years ago

@MrRefactoring do you think we can include the version option in jira-connector getAllProject call?

I think it can be done. Could you get an issue so that I don't forget to do this in my free time?

gioboa commented 5 years ago

I reopened this issue https://github.com/floralvikings/jira-connector/issues/177 @kpolivier I will prepare a new version of jira-plugin.

gioboa commented 5 years ago

@kpolivier I cannot reproduce the problem in my Jira. Could you try this version for me please? In this new version first we call v3 API for projects and v2 is the fallback call. --- file removed --- Let me know, thanks. 👍

kpolivier commented 5 years ago

for me it's good. I even try to replace line 72 of http.service.js with "apiVersion: '2'" to test with v2 and I got no projects as it was for yesterday so I think everything is alright...(except the bug from atlassian with api v2 for me...) Thank you for your job.