【问题标题】:Instagram Authentication issueInstagram 身份验证问题
【发布时间】:2016-10-26 23:58:40
【问题描述】:

在我的应用程序中,我有 3 种不同的方式来使用 Instagram Auth,并且需要根据操作重定向到 3 个不同的位置。因此,我有 3 个不同的身份验证网址

我注册的重定向网址是http://nameoftheapp.com/folder/

验证 URL 1 是

https://api.instagram.com/oauth/authorize/?client_id='
    + ig_id
    + '&response_type=code&redirect_uri='
    + encodeURI('http://nameoftheapp.com/folder/?l=r'); 

验证 URL 2 是

https://api.instagram.com/oauth/authorize/?client_id='
    + ig_id
    +'&response_type=code&redirect_uri='
    + encodeURI('http://nameoftheapp.com/folder/?l=g');

验证 URL 3 是

https://api.instagram.com/oauth/authorize/?client_id='
    + ig_id
    +'&response_type=code&redirect_uri='
    + encodeURI('http://nameoftheapp.com/folder/?l=l');

现在所有这些 URL 都将我返回到正确的 URL,并附加了代码,准备好转换为访问令牌。

没有 EncodeURI 中的参数,这让我可以访问我需要的数据。如果我保留这些参数,我会收到下面的 HTTP400 错误

[23-Aug-2014 10:26:40 Europe/Berlin] Array
(
    [code] => 400
    [error_type] => OAuthException
    [error_message] => Redirect URI doesn't match original redirect URI
)

如果您查看 Instagram 文档上的此页面,它会说它允许您使用参数 http://instagram.com/developer/authentication/

【问题讨论】:

  • 不是参数,我认为是encodeURI()故障jsfiddle.net/zzkw0o9u也许你只需要编码参数值,而不是完整的URI

标签: instagram


【解决方案1】:

我在通过 PHP 获取访问令牌时遇到了同样的问题,我使用相同的 redirect_uri 的 URL 发出,例如:

如果登录 Instagram 后使用的 Auth URL 是 http://nameoftheapp.com/folder/?l=l,则会将您发送到 redirect_uri http://nameoftheapp.com/folder/?l=l&code=<CODE>。因此,在此文件中的 CURL 参数中,要从 Instagram 获取信息或访问令牌,请使用相同的 URL http://nameoftheapp.com/folder/?l=l 和相同的 GET 变量。

我知道这是一篇旧帖子,但这可能对像我这样在这篇帖子中寻找答案的人有所帮助。

【讨论】:

    【解决方案2】:

    文档显示

    注册的重定向 URI http://yourcallback.com/callback

    你有

    我注册的重定向网址是http://nameoftheapp.com/folder/

    尝试删除结尾的斜线...?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多