我正在为我的应用程序中的Trello集成添加OAuth流。这个想法是使用深度链接来消耗应用程序本身内的响应(应用程序和数据库之间没有服务器-我正在使用房间)。
到目前为止,除了回调重定向部分,我已经完成了所有工作,它可以在我的真实设备上运行,而不是在模拟器上运行。
这是开始OAuth流程的代码。
val connection = object:CustomTabsServiceConnection() {
override fun onCustomTabsServiceConnected(name: ComponentName, client: CustomTabsClient) {
val builder = CustomTabsIntent.Builder()
val customTabsIntent = builder.build()
client.warmup(0)
var authUrl = "$TOKEN_URL?key=$API_KEY&scope=read&callback_method=fragment&return_url=${AuthenticationManager.HTTPS_REDIRECT_URL}&expiration=never&name=$NAME&integration=${integration.id}"
customTabsIntent.launchUrl(context, Uri.parse(authUrl))
}
override fun onServiceDisconnected(name: ComponentName?) {
}
}
bindCustomTabsService(context, "com.android.chrome", connection);
清单
<activity
android:name="com.myapp.MainActivity"
android:screenOrientation="sensor"
android:windowSoftInputMode="adjustPan"
android:launchMode="singleTop"
android:configChanges="uiMode">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="pomodoro" android:host="oauth.myapp.com"/>
<data android:scheme="https" android:host="myapp.com"/>
</intent-filter>
</activity>
此时,它被重定向到我的网页,我在真实设备上验证了该网页后,将其重定向到我的应用程序(因此它可以消耗意图并获得必要的令牌)。我想知道当我为Chrome浏览器选择“始终使用”时(最初在模拟器中打开网页时),这是否会覆盖我的深层链接?那可能吗?也无法使用其他方案,因为Trello强制使用https / http作为受信任的重定向/回调URL?
这与我对Deeplink与AppLink的误解有关。我想将其更多地视为AppLink而不是Deeplink,这意味着已经进行了验证(该URL属于我的应用程序)(通过我域中的文件)。为了进行此验证,我需要在适当的URL处提供验证文件(如果不存在)-无法进行验证。每个主机/方案都会发生这种情况,并且必须验证所有匹配项。