2016-08-17 58 views
1

最近我一直在学习有关反应原生,我遇到了一个如此农场无法解决的问题。 我尝试使用Gmail的OAuth2从我的应用程序进行身份验证,作为重定向参数我把myscheme:// OAuth的整个URL看起来是这样的:反应原生OAuth2 redirect_uri:无效的计划

https://accounts.google.com/o/oauth2/v2/auth?response_type=token&client_id=XXXXXXXX&redirect_uri=myscheme://oauth&scope=https://www.googleapis.com/auth/spreadsheets

我注册的意图过滤器在我的清单.XML它看起来像这样:

<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> 

我使用原生反应链接打开URL,我得到(浏览器)的错误是REDIRECT_URI 400参数值无效:无效的方案:myscheme://的OAuth

任何人都可以帮助我什么,我在这里失踪?

回答

0

the docs,我看到了两个问题,您的网址:

  1. 定制方案必须包含一个周期内为有效

变化myscheme喜欢的东西com.myapp

  • 注意单个 “/” 自定义URI方案,其不同于常规的HTTP URL
  • 变化myscheme://oauth...myscheme:/oauth...

    后这些更正后,您的网址应该看起来像com.myapp.myscheme:/oauth...而不是myscheme://oauth...