Instagram:重定向URI与注册的重定向URI不匹配

Gag*_*aga 3 oauth instagram

错误

{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}
Run Code Online (Sandbox Code Playgroud)

出现了

https://instagram.com/oauth/authorize?response_type=code&client_id=2fa4359e4340434786e469ab54b9b8c0&redirect_uri=http://localhost:8000&scope=likes
Run Code Online (Sandbox Code Playgroud)

Instagram设置

CLIENT ID   2fa4359e4340434786e469ab54b9b8c0
WEBSITE URL http://localhost:8000/
Run Code Online (Sandbox Code Playgroud)

$authProvider.oauth2({
  name: 'instagram',
  url: 'http://localhost:3000/auth/instagram',
  redirectUri: 'http://localhost:8000',
  clientId: '2fa4359e4340434786e469ab54b9b8c0',
  requiredUrlParams: ['scope'],
  scope: ['likes'],
  scopeDelimiter: '+',
  authorizationEndpoint: 'https://api.instagram.com/oauth/authorize'
});
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.谢谢!

Han*_* Z. 5

您需要对redirect_uri参数的值进行URL编码,http%3A%2F%2Flocalhost%3A8000以防止scope参数成为redirect_uri值的一部分而不是授权请求.

您还必须确保redirect_uri匹配完全匹配,包括您已注册的最后一个斜杠.

那么授权请求变为:

https://instagram.com/oauth/authorize?response_type=code&client_id=2fa4359e4340434786e469ab54b9b8c0&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=likes
Run Code Online (Sandbox Code Playgroud)