【发布时间】:2021-03-18 19:33:23
【问题描述】:
我是 Android 新手,正在尝试在网站上使用 oauth2 对应用进行身份验证(我只能在其中设置集成、获取 ClientId 并定义 redirect_uri)。本网站仅允许将 Uris 作为重定向。它不允许自定义方案,例如:“br.com.myapp:/oauth2redirect”。 鉴于此,我在网站上将“http://br.com.myapp/oauth2redirect”设置为我的 redirect_uri。
我正在使用 AppAuth:
implementation 'net.openid:appauth:0.8.1'
在我的清单文件中,我在下面添加了意图过滤器:
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace">
<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="http"
android:host="br.com.myapp"
android:pathPrefix="/oauth2redirect" />
</intent-filter>
</activity>
在我的“build.gradle”中,我设置:
manifestPlaceholders = [
'appAuthRedirectScheme': 'br.com.myapp'
]
好吧,应用程序打开了一个 CustomTabsIntent,其中打开了目标 oauth 提供程序网站。我能够插入用户/通行证。然后我被重定向到提供商网站上的另一个页面,我需要在该页面上接受身份验证,然后会打开一个空白页面并显示以下消息:
This site can't be reached
br.com.myapp's server IP address could not be found
DNS_PROBE_FINISHED_NXDOMAIN
它指向的地址是我的重定向 uri:http://br.com.myapp/oauth2redirect?code=xxxx&state=xxxx
据我所知,这是正确的。问题是我的应用程序没有捕捉到这个意图。有什么建议吗?
提前致谢!
【问题讨论】: