[英]Hook result of oauth request from web application to Twitter in Android app
I have website, that implements "Sign in with twitter".我有一个网站,它实现了“用 twitter 登录”。
This authorization process: My site redirects user to twitter, then twitter asks user to allow my website access his account, he clicks "Allow", twitter redirects user back to my site, that gets access token.此授权过程:我的网站将用户重定向到 twitter,然后 twitter 要求用户允许我的网站访问他的帐户,他点击“允许”,twitter 将用户重定向回我的网站。
Also I have an Android app, that needs to initialize this auth process and finally get result.我还有一个 Android 应用程序,它需要初始化这个身份验证过程并最终得到结果。 I can create intent, that opens url in browser, and all next steps go in browser, but can I hook somehow when browser is closed, or (that will be better) when browser gets final redirect, to check if authorization was OK and my website now can access user's twitter account, and close browser?我可以创建意图,在浏览器中打开 url,并在浏览器中打开所有后续步骤 go,但是我可以在浏览器关闭时以某种方式挂钩,或者(这会更好)当浏览器获得最终重定向时,检查授权是否正常以及我的网站现在可以访问用户的twitter账号,关闭浏览器了吗?
Do I need investigate about WebView, or this functionality can be implemented using regular Android browser?我是否需要调查 WebView,或者这个功能可以使用常规的 Android 浏览器来实现?
I believe what you are looking for is setting up a custom scheme .我相信您正在寻找的是设置自定义方案。 With this you can set up a appname as a scheme and when you generate a request token from Twitter with an oauth_callback
as appname://callback
the user will be redirected back to that uri after authorizing and it will open your app.有了这个,您可以将 appname 设置为方案,当您从 Twitter 生成请求令牌时, oauth_callback
为appname://callback
,用户将在授权后被重定向回该 uri,它将打开您的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.