首页 > 解决方案 > Instagram redirect_url 剥离查询字符串

问题描述

所以我正在开发一个 Instagram 基本显示调用,出于某种原因,它正在剥离一个查询字符串。

以下是所有信息
/auth/authenticate/ 按钮所在的位置:***/wp-admin/options-general.php?page=instagram_auth

$auth_url .= '/?client_id=' . $this->instagram->get_client_id() . '&redirect_uri=' . $this->instagram->get_redirect_uri() . '&scope=user_profile,user_media&response_type=code';

身份验证窗口会弹出以下代码,然后我可以进行身份​​验证:

https://www.instagram.com/oauth/authorize/?client_id=28822****&redirect_uri=****/wp-admin/options-general.php?page=instagram_auth&scope=user_profile,user_media&response_type=code

这是问题所在:

当我点击“接受”时,Instagram 会重定向到:

/wp-admin/options-general.php?code=AQBWjP-foZA7tkhUCTZygn5CBNbiJJxmY364eLPm0bD9NpetQbzUqJSw4LiueRDg_jiDzW8l_8js2JHFAZcPom8zFR-86x_*-X11H1-kTPCPrQ#_

它去除了?page=instagram_auth我的代码中需要的参数。我的有效 OAuth 重定向 URI 是:***/wp-admin/options-general.php?page=instagram_auth

有谁知道为什么参数被剥离?

标签: phpwordpressfacebook-graph-apiinstagram

解决方案


有一个state参数可以添加到 OAuth 授权请求中,当它重定向到您的重定向 URI 时将通过该参数。

An optional value indicating a server-specific state. For example, you can use this to protect against CSRF issues. We will include this parameter and value when redirecting the user back to you.

(来自 Facebook Instagram API 文档) https://developers.facebook.com/docs/instagram-basic-display-api/reference/oauth-authorize


推荐阅读