我已使用passport.js在我的Node.js服务器上设置了第三方OAuth身份验证。
它适用于浏览器。流程如下:
myserver.com/auth/instagram
server.com/auth/instagram/callback
res.send(myAccessToken)
给了客户。我在Android中遇到麻烦。要键入第三方凭据,需要一个浏览器页面。但那么我将如何在我的应用程序中获得最终结果呢?
选项1
启动浏览器。
Intent i = new Intent(ACTION_VIEW);
i.setData(Uri.parse("https://myserver.com/auth/instagram"));
startActivity(i);
的问题:
myAccessToken
的空白页。选项2
使用一些http库连接。
final Request request = createRequest()
.url("https://myserver.com/auth/instagram")
.get()
.build();
Response response = client.newCall(request).execute();
的问题:
200
响应。当然,用户永远不会被提示他的Instagram凭证,因为没有浏览器曾经打开过。如何处理?
注意: