ios – 处理SFSafariViewController中的d出窗口选项卡

ios – 处理SFSafariViewController中的d出窗口选项卡,第1张

概述我正在我的应用程序中实现SoundCloud登录流程.该应用程序在SFSafariViewController中打开https://soundcloud.com/connect,其中redirect_uri使用我的应用程序的自定义URL方案来接收响应.它适用于直接的SoundCloud登录,但在尝试使用“使用Google登录”按钮时失败. 在Safari中,该按钮会打开一个带有Google登录页面 我正在我的应用程序中实现SoundCloud登录流程.该应用程序在SFSafariVIEwController中打开@R_419_6822@s://soundcloud.com/connect,其中redirect_uri使用我的应用程序的自定义URL方案来接收响应.它适用于直接的SoundCloud登录,但在尝试使用“使用Google登录”按钮时失败.

在Safari中,该按钮会打开一个带有Google登录页面的新选项卡(桌面d出窗口),然后通过postMessage与SoundCloud选项卡进行通信.如果您使用iOS Safari应用程序,此登录流程可以正常工作,但在SFSafariVIEwController中失败(单击该按钮会转到带有Google网址的白页:@R_419_6822@s://accounts.Google.com/o/oauth2/auth?.. ).

现在我的解决方法是建议使用Google的用户点击SFSafariVIEwController上的Safari图标来完成Safari应用程序中的登录流程,但我想知道是否有办法在不离开我的应用程序的情况下处理此问题.

解决方法 好吧,如果我使用UIWebVIEw,您可以在用户通过Google进行身份验证后从谷歌获取最终的oauth响应.但是,我们如何将其转回SoundCloud(例如soundcloud.com/connect/via/Google_plus/returning)

- (voID) webVIEwDIDFinishLoad:(UIWebVIEw*)inWebVIEw {    Nsstring* str = [inWebVIEw stringByEvaluatingJavaScriptFromString:@"document.getElementByID('response-form-encoded').value"];    if ( str.length > 0 ) {        NSDictionary* params = parseURLParams( str );        NSLog( @"%@",params );    }}

输出:

{    "access_token" = "ya2...<removed>...4g";    authuser = 0;    code = "4/sU_g7....<removed>...fnRELA";    "expires_in" = 3600;    "ID_token" = "eyJhb...<removed>...DA";    prompt = none;    scope = "@R_419_6822@s://www.GoogleAPIs.com/auth/userinfo.email+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.login+@R_419_6822@s://www.GoogleAPIs.com/auth/userinfo.profile+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.moments.write+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.me+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.profile.agerange.read+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.profile.language.read+@R_419_6822@s://www.GoogleAPIs.com/auth/plus.circles.members.read";    "session_state" = "c8703a085b885bbe8c8d0e29277b0c2fdf9c6c87..65aa";    state = "392921654%7C0.288515904";    "token_type" = Bearer;}

启动谷歌登录步骤的URL如下所示 – 为方便起见,我已解码下面的URL转义编码:

@R_419_6822@s://accounts.Google.com/o/oauth2/auth?clIEnt_ID=984739005367.apps.Googleusercontent.com&response_type=code token ID_token gsession&scope=@R_419_6822@s://www.GoogleAPIs.com/auth/userinfo.email @R_419_6822@s://www.GoogleAPIs.com/auth/plus.login @R_419_6822@s://www.GoogleAPIs.com/auth/userinfo.profile&state=425511939|0.2912748339&access_type=offline&request_visible_actions=@R_419_6822@://schemas.Google.com/AddActivity @R_419_6822@://schemas.Google.com/ListenActivity @R_419_6822@://schemas.Google.com/CreateActivity&after_redirect=keep_open&cookie_policy=single_host_origin&prompt=none&include_granted_scopes=true&proxy=oauth2relay751149297&redirect_uri=postmessage&origin=@R_419_6822@s://soundcloud.com&gsiwebsdk=1&authuser=0&Jsh=m;/_/scs/apps-static/_/Js/k=oz.gAPI.en.TA32fes-0yU.O/m=__features__/am=AQ/rt=j/d=1/rs=AGLTcCOuWxpcbMjoomrZx_gBsAG8J20NLA
总结

以上是内存溢出为你收集整理的ios – 处理SFSafariViewController中的d出窗口/选项卡全部内容,希望文章能够帮你解决ios – 处理SFSafariViewController中的d出窗口/选项卡所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1002995.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存