Platform
注册Instagram帐户
8 分
instagram oauth 教程 介绍 instagram oauth 使用户能够通过 oauth 使用他们的 instagram 账户登录应用程序。 先决条件 要完成本教程,您需要: 在 back4app 创建的应用程序 查看 https //www back4app com/docs/get started/new parse app 以了解如何在 back4app 上创建应用程序。 为您的 back4app 应用程序设置子域名 查看 https //www back4app com/docs/platform/activating web hosting 以了解如何在 back4app 中创建子域名。 一个 https //developers facebook com/docs/instagram 。 1 创建一个新的 back4app 应用程序 首先,您需要确保在 back4app 上有一个现有的应用程序。如果您是新用户,可以查看 https //www back4app com/docs/get started/new parse app 以了解如何创建一个。 2 创建一个新的 instagram 应用客户端 登录到您的 https //www instagram com/developer/ 并注册为开发者。 输入您的网站、电话和应用程序描述。接受条款以继续。 转到概述。点击 注册您的应用程序 注册您的应用程序 点击 注册新客户端 注册新客户端 填写 应用名称 应用名称 , 描述 描述 , 公司名称 公司名称 , 网站网址 网站网址 , 重定向 uri 重定向 uri , 隐私政策网址 隐私政策网址 , 和 联系邮箱 联系邮箱 对于 有效的重定向 uri 有效的重定向 uri , 如果您只是想获取访问令牌,可以将其留空 http //localhost 否则,您应该使用生产 uri 进行重定向 此时,您应该有一个像下面图像的客户端 点击 管理 管理 ,在 安全 安全 标签下,取消勾选 禁用隐式oauth 禁用隐式oauth 3 获取您的令牌 如果您将 重定向uri 重定向uri 设置为 localhost localhost ,您可以通过两种方式获取您的令牌。 第一种是使用您选择的浏览器,访问以下url https //api instagram com/oauth/authorize/?client id=client id\&redirect uri=redirect uri\&response type=code 只需更改 client id client id 和 redirect uri redirect uri 使用您从新创建的客户端获得的值。 这将重定向您到一个无效页面,但会在url中显示访问令牌 获取此类令牌的另一种方法是运行以下curl命令,替换 client id client id , client secret client secret , 和 redirect uri redirect uri 为您的值 1 curl \\ f 'client id=client id' \\ 2 f 'client secret=client secret' \\ 3 f 'grant type=authorization code' \\ 4 f 'redirect uri=redirect uri' \\ 5 f 'code=code' \\ 6 https //api instagram com/oauth/access token 该命令还将输出您的访问令牌。 4 开始开发 现在instagram登录已配置,您可以开始开发过程,传递您为身份验证检索的访问令牌。 authdata的格式为 1 { 2 "instagram" { 3 "id" "user's instagram id (string)", 4 "access token" "an authorized instagram access token for the user" 5 } 6 } 这是ios sdk的方法: 1 pfuser loginwithauthtype(inbackground "instagram", authdata \["access token"\ tokenstring, "id" user]) continuewith { task > any? in 2 3 } 这里是android sdk的方法: 1 map\<string, string> authdata = new hashmap\<string, string>(); 2 authdata put("access token", tokenstring); 3 authdata put("id", user); 4 parseuser loginwithinbackground("instagram", authdata){ 5 6 }