英文:
BitBucket Cloud's Oauth implicit grant method stopped working in electron app
问题
我之前在我的Electron应用程序中使用BitBucket Cloud的OAuth隐式授权方法来验证我的应用程序,以获取我的存储库的详细信息。
最近它停止工作了。
隐式授权方法的参考链接:
https://bitbucket.org/atlassian/bb-cloud-implicit-grant-sample-app/src/master/
我注意到,即使我直接打开登录页面,它也不起作用。
以下是代码示例:
let win = new remote.BrowserWindow({ width: 800, height: 600, show: false, webPreferences: { sandbox: true }});
win.loadURL('https://id.atlassian.com/login'); // 这已经停止工作
有什么想法为什么会这样?
英文:
I was using BitBucket Cloud's Oauth implicit grant method in my electron app for authenticating my app to fetch the details of my repositories.
It stopped working recently.
Reference link of implicit grant method:
https://bitbucket.org/atlassian/bb-cloud-implicit-grant-sample-app/src/master/
I noticed that even if I directly open login page its not working.
Here is the code example:
let win = new remote.BrowserWindow({ width: 800, height: 600, show:false, webPreferences: {sandbox: true, }});
win.loadURL('https://id.atlassian.com/login'); // this stopped working
Any idea why?
答案1
得分: 1
解决方案
通过将用户导航到实际浏览器而不是应用内浏览器(以授权,其中 id.atlassian.com 不受限制并且有效),然后通过 Bitbucket 中的重定向 URL 配置将用户返回到应用以使用令牌进行进一步处理进行身份验证。
与在我的 electron
应用中使用以下代码不同
win.loadURL('https://bitbucket.org/site/oauth2/authorize?client_id={CLIENT_ID}&response_type=token')
我使用了
shell.openExternal('https://bitbucket.org/site/oauth2/authorize?client_id={CLIENT_ID}&response_type=token');
影响
用户流程有所不同,因为现在用户将从应用程序转到浏览器,然后从浏览器返回到应用程序以获取令牌。之前一切都在应用程序内进行。
英文:
As a workaround I've fixed the issue and its not a blocker anymore.
Solution
By navigating the user to actual browser instead of in-app browser (to authorize
where id.atlassian.com is not restricted and works) and then via redirect url configuration in Bitbucket, returning the user back to the app to authenticate the app with token for further processing.
Instead of using below code in my electron
app
win.loadURL('https://bitbucket.org/site/oauth2/authorize?client_id={CLIENT_ID}&response_type=token')
I've used
shell.openExternal('https://bitbucket.org/site/oauth2/authorize?client_id={CLIENT_ID}&response_type=token');
Impact
The user flow is bit different, because now user will move from app to browser and then browser to app with token. Earlier everything was happening within the App.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论