【问题标题】:C# Instagram - Invalid ScopeC# Instagram - 无效范围
【发布时间】:2020-06-29 23:03:54
【问题描述】:

我正在创建一个网站,我想在其中显示 Instagram 帖子。 我需要access_token,所以我按照流程,尝试获取“代码” 一次成功,但再也没有......

消息总是

"{"error_type": "OAuthException", "code": 400, "error_message": "无效范围字段:basic,user_profile,user_media"}"

string authUri = "https://api.instagram.com/oauth/authorize/?client_id=" + _clientID +
                    "&redirect_uri=" + redirectUri +
                    "&scope=user_profile,user_media" +
                    "&response_type=code";

        Process.Start(authUri);

我尝试删除范围行,然后错误是 Invalid scope field(s): basic 当我与 scope=basic 一起使用时,相同的消息,无效的范围字段:基本

我尝试使用 Instagram 客户端 ID/令牌,同样的错误,尝试使用 Facebook 应用程序中的 Instagramm ID/Secret,同样的错误。

有什么想法吗?

提前致谢

【问题讨论】:

  • 我认为你的网址不正确试试string authUri = "https://api.instagram.com/oauth/authorize?client_id=" + _clientID +"&redirect_uri=" + redirectUri +"&scope=user_profile,user_media" +"&response_type=code";

标签: c# oauth instagram


【解决方案1】:

昨天开始发生这种情况。

Instagram 于 6 月 29 日(昨天)弃用了 basic 范围。看起来他们可能有一个错误,导致 basic 被添加到您要求的任何有效范围中。实际上,这似乎是禁用了整个 oauth 功能。

希望他们能解决这个问题?但谁知道呢。

您可能只需要等待。

【讨论】:

    【解决方案2】:

    是的,该 API 已于今天(6 月 30 日)弃用。

    网址应该是https://www.instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=REDIRECTURI&response_type=code&scope=instagram_graph_user_media

    但正如@david 在我之前所写的那样,由于“基本”权限已添加到任何请求中,因此现在有些问题。

    2020 年 7 月 4 日更新

    解决了。必须从 Facebook 创建一个新的 Instagram 应用,然后用新的 ID 替换客户端 ID,更新客户端密码,更新调用 URL,创建新的测试用户,更新令牌,并且通常更新整个代码,因为从端点现在是完全不同的格式。相当的工作。但它现在正在工作。

    【讨论】:

    • 你能在这里分享示例代码吗,因为我已经完成了所有这些事情,但仍然遇到同样的问题。我已更改客户端 ID 和密码,但随后出现无效的重定向 uri 异常
    【解决方案3】:

    我得到了完全相同的错误响应:

    {"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope field(s): basic,user_profile,user_media"}
    

    我通过将旧的、过时的 INSTAGRAM_CLIENT_ID 更改为新的 INSTAGRAM_APP_ID 来修复它。您可以在https://developers.facebook.com/apps 中找到它。确保您获取的是专门针对 Instagram 基本展示产品的 APP_ID,而不是您的整个 Facebook 应用 ID

    https://api.instagram.com/oauth/authorize?client_id={THE NEW APP ID, not the old client ID} & {the rest of the params} 
    

    【讨论】:

      【解决方案4】:

      您可以简单地使用:“https://www.instagram.com/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&scope=user_profile,user_media&response_type=code” 注意: redirect_uri 必须在 https

      【讨论】:

      • 很好,但请使用Code Sample 格式按钮 ({}) 进行代码粘贴。这使您的答案更具可读性。谢谢。
      【解决方案5】:

      我今天遇到了这个问题,我做了两件事:

      • 清除浏览器的 cookie(确保使用“所有时间”选项清除所有 cookie,而不是持续 1 周或其他任何时间)。

      • 在应用上重置密码

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-10-14
        • 1970-01-01
        • 1970-01-01
        • 2019-06-18
        • 1970-01-01
        • 2021-03-29
        • 2018-12-06
        相关资源
        最近更新 更多