为PhoneGap设置有效的Azure AD uri [英] Setting a valid Azure AD uri for PhoneGap

查看:57
本文介绍了为PhoneGap设置有效的Azure AD uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PhoneGap框架开发移动应用程序.对于项目的下一部分,我需要允许用户通过其公司的Windows 365帐户进行身份验证.为此,我正在使用Azure AD,并使用以下基于AngularJS的库.

I am working on a mobile app, using the PhoneGap framework. For the next part of the project, I need to allow users to authenticate themselves through their Windows 365 account of the company. For this I'm using Azure AD, with the following AngularJS based library.

我已经成功使用本地主机进行了身份验证调用.但是,对于下一步,我需要使身份验证在所有移动设备上都可用.为此,我需要设置一个合适的Uri,默认情况下,Android似乎以file:///android_asset/模板的形式提供.尽管Azure AD似乎将其识别为有效" URI,但它拒绝进行身份验证.

I have already succeeded on making the Authentication call using localhost. For the next step however I need to make the authentication usable on all mobile devices. For this I need to set up a proper Uri(s), which by default Android appears to provide as a file:///android_asset/ template. While Azure AD seems to recognize this as a "valid" URI, it refuses to make the authentication.

所以精简我的问题.如何设置有效的Uri,以便可以在移动设备上实现身份验证?

So to boil down my question. How do I set a valid Uri so that the authentication can be achieved on mobile devices?

其他信息: PhoneGap是基于HTML5和基于javascript的-如果任何JS或Jquery类都可以帮助解决此问题,请随时转发它们.其他正在使用的库是Jquery Mobile和AngularJS. (尽管后者几乎仅用于执行身份验证)是示例I基于身份验证.

Additional information: PhoneGap is HTML5 and javascript-based - Should any JS or Jquery classes be able to help in this matter, feel free to forward them. Other libraries being used are Jquery Mobile and AngularJS. (Though the latter used almost solely to perform the authentication) this is the sample I based the authentication on.

推荐答案

经过一些进一步的研究,我设法找到了验证问题的解决方案.通过Azure进行身份验证的问题是Azure需要有效的返回uri.起初我曾考虑过实现自定义网址方案以使其返回,但这也被认为是无效的.

After some further research, I managed to find a solution to the authentication problem. The problem with authentication through Azure is that Azure expects a valid return uri. I had at first considered implementing a custom url scheme for it to return to, but this was also not considered valid.

因此,我们研究了更多选项.看来,Azure确实提供了移动服务,这些移动服务可能使应用程序内部的身份验证成为可能.但是,我们希望尽可能地具有成本效益.我建议,如果您遇到类似的问题,请首先调查一下它们,但这是我们不这样做的方式.我希望有人会觉得有用.

So we looked at further options. It appears that Azure does offer mobile services which could have made authentication within the app itself possible. However, we wanted to be as cost-effective as possible. I advice, if you're faced with a similar problem to look into them first, but this is how we did it without. I hope someone may find it useful.

我使用的方法是在公司的网站上执行身份验证.整个过程由四个HTML页面组成-2个用于登录,2个用于注销. (当然还有必需的JS文件-请参阅问题.)

The method I used was to perform the authentication on the company's website. The entirety of this consists out of four HTML pages- 2 For logging in, 2 for logging out. (With the requisite JS files of course - See the question.)

将发生的情况是,当浏览到这些页面之一时,您将立即被重定向到Windows 365以对自己进行身份验证.登录后,您将被重定向到提供应用程序所需信息的页面. (但隐藏)注销时使用了类似的过程.

What would happen is that when browsing to one of these pages, you would immediately be redirected to Windows 365 to authenticate yourself. Upon logging in, you would be redirected to a page where the information the application needs is provided. (but hidden) A similar process was used in logging out.

此难题的最后一步是使应用程序转到此页面,然后检测身份验证何时完成.为此,我使用了Cordova插件inappbrowser. https://github.com/apache/cordova-plugin-inappbrowser

The final step in this puzzle was to make the app go to this page, then detect when the authentication was complete. For this I used a cordova plugin, inappbrowser. https://github.com/apache/cordova-plugin-inappbrowser

基于事件网址,我可以让该应用检测身份验证何时完成(或注销完成)并采取相应措施.

Basing myself on the event url, I could have the app detect when authentication was completed (or logging out was completed) and act accordingly.

这篇关于为PhoneGap设置有效的Azure AD uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆