【发布时间】:2020-07-14 09:28:10
【问题描述】:
我正在努力将 OAuth 流添加到我的应用程序中的 Trello 集成中。这个想法是使用深度链接来使用应用程序本身的响应(应用程序和数据库之间没有服务器 - 我正在使用房间)。
到目前为止,除了回调重定向部分之外,我已经完成了所有工作,并且它可以在我的真实设备上运行,而不是在模拟器上运行。
这是开始 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?
【问题讨论】:
标签: android kotlin oauth deep-linking