【发布时间】:2016-08-02 09:51:35
【问题描述】:
我确定这是基本的,但我遗漏了一些东西。我已经阅读了关于 SO 的其他答案,我用谷歌搜索过,我已经阅读了资源,但我无法理解我需要做什么。
我试图弄清楚如何编写一个连接到 Twitch API 的应用程序,特别是如何使用 Twitch 的 API 进行身份验证。他们的文档在这里:https://github.com/justintv/Twitch-API/blob/master/authentication.md
我创建了一个应用程序并存储了我的密钥。
现在是我希望我的用户单击在其网站上启动身份验证的按钮的部分。据我所知,我是通过使用 AccountManager 来做到这一点的。除了...我不知道我应该做什么。
这是我在网上找到的摘录:
AccountManager am = AccountManager.get(this);
Bundle options = new Bundle();
am.getAuthToken(
myAccount_, // Account retrieved using getAccountsByType()
"Manage your tasks", // Auth scope
options, // Authenticator-specific options
this, // Your activity
new OnTokenAcquired(), // Callback called when a token is successfully acquired
new Handler(new OnError())); // Callback called if an error occurs
根据 twitch 的文档,我想将用户发送到:
https://api.twitch.tv/kraken/oauth2/authorize
?response_type=code
&client_id=[your client ID]
&redirect_uri=[your registered redirect URI]
&scope=[space separated list of scopes]
&state=[your provided unique token]
我根本不知道这两个东西需要如何结合。
【问题讨论】:
标签: java android api oauth accountmanager