我正在将react-native-instagram-login
用于React Native。
这是我的代码
react-native-instagram-login
我收到以下错误
<InstagramLogin ref={instagramLoginRef} appId='***********' appSecret='*******************' scopes={['user_profile', 'user_media']} onLoginSuccess={(data) => console.log("Success")} onLoginFailure={(data) => console.log("Fail " + JSON.stringify(data))} />
在Instagram开发者控制台中,我应该添加什么作为重定向Uri,因为这不是网站,而是React Native应用。
来自{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}
:
有效的OAuth重定向URI
输入您的网站的URL。通常这个将是专用的URI,可以捕获重定向查询字符串参数,但对于本教程,您网站的URL会很好。
例如:Instagram Basic Display API
输入URL后,保存更改并再次检查URL;我们可能会根据您的网址附加一个斜杠结构体。将完整的URL复制到某处,因为您将需要它随后的步骤以获取授权码和访问令牌。
在此https://socialsizzle.heroku.com/auth/
,我们看到example code,这意味着您可以设置所需的任何内容。这对于收集登录数据统计信息并具有用于记录日志的后端端点很有用。
redirectUrl='https://www.google.com'
[也来看看这个问题<InstagramLogin
ref={instagramLoginRef}
clientId="931cca1d0c154de3aafd83300ff8b288"
redirectUrl="https://google.com"
scopes={['basic']}
onLoginSuccess={token => this.setState({ token })}
onLoginFailure={data => this.setState({ failure: data })}
/>
,它说,由于"no response when completed"中的错误,redirectUrl
必须以www
开头。同样在此问题上,您将看到用户示例代码具有Firebase函数终结点URL react-native-webview
,因此它使用Firebase记录/反馈登录请求。
最后,在Facebook开发者控制台中,您只需输入有效的OAuth重定向URI:
redirectUrl="https://us-central1-xxx.cloudfunctions.net/url_get&response_type=token"
这意味着您输入接受API重定向的URL;它更像是一种安全机制,但是您必须在此处输入重定向URL,否则API将无法正常工作。