将用户发送到授权端点以获取授权代码

你将首先将用户发送到 Twitch 授权端点。此 URL 由基本授权 URL(https://api.twitch.tv/kraken/oauth2/authorize)和定义你请求的查询字符串参数组成。所需参数为 response_typeclient_idredirect_uriscope

对于授权代码流,response_type 参数始终设置为 code。这表示你正在从 Twitch API 请求授权代码。

redirect_uri 是用户在批准你的应用程序请求的范围后将被重定向的位置。这必须与你在 Twitch 帐户“ 连接”页面上注册的内容相匹配。

client_id 是你的应用程序的唯一标识符。你也可以在 Connections 页面上找到你的客户端 ID。

scope 定义了你代表用户访问的内容。你应该只请求应用程序运行所需的最低要求。你可以在 Twitch API GitHub 上找到范围列表。

还支持 state 参数以帮助防止跨站点脚本攻击。当用户授权你的应用程序时,state 参数将包含在 redirect_uri 中。

  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]