我是安卓的新手,我正试图在网站上使用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
据我所知,这是正确的。问题是我的应用程序没有捕捉到这个意图。有小费吗?
提前感谢!
发布于 2022-03-09 15:37:18
我相信您需要将android:exported设置为"true",请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported
示例:
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace"
android:exported="true">
<intent-filter>
...https://stackoverflow.com/questions/66697927
复制相似问题