反应本机OAuth2 redirect_uri:无效的方案 [英] React native OAuth2 redirect_uri: Invalid scheme
问题描述
最近,我一直在学习有关本机响应的问题,并且遇到了一个农场无法解决的问题. 我正在尝试从我的应用中使用gmail OAuth2进行身份验证,作为重定向参数,我将myscheme://oauth放在了整个网址中,如下所示:
recently I've been learning about react native and I encountered a so farm unsolvable problem. I'm trying to authenticate using gmail OAuth2 from my app, as a redirect parameter I put myscheme://oauth the whole url looks like this:
我在manifest.xml中注册了一个意图过滤器,如下所示:
I registered an intent-filter in my manifest.xml which looks like this:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myscheme" android:host="oauth"/>
</intent-filter>
</activity>
我正在使用react native Linking打开URL,并且在浏览器中收到的错误是400 redirect_uri的参数值无效:无效的方案:myscheme://oauth
I am using react native Linking to open the URL and the error I get (in the browser) is 400 Invalid parameter value for redirect_uri: Invalid scheme: myscheme://oauth
有人可以帮我在这里想念我什么吗?
Can anyone help me what am I missing here?
推荐答案
来自文档,我发现您的网址有两个问题:
From the docs, I see two problems with your URL :
- 自定义方案必须包含一个有效期
将myscheme
更改为com.myapp
.
- 请注意自定义URI方案后的单个"/",这与常规HTTP URL不同
将myscheme://oauth...
更改为myscheme:/oauth...
进行这些更正后,您的网址应类似于com.myapp.myscheme:/oauth...
而不是myscheme://oauth...
After those correction, your URL should look like com.myapp.myscheme:/oauth...
instead of myscheme://oauth...
这篇关于反应本机OAuth2 redirect_uri:无效的方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!