问题描述
我正在使用 appAuth-android 登录我的应用程序,并且我想传递自定义标头。为了允许自定义标题,我已经完成了数字资产链接建议的所有事情。
private var session: CustomTabsSession? = null
private var customTabsIntent: CustomTabsIntent? = null
private var callback: CustomTabsCallback = object : CustomTabsCallback() {
override fun onRelationshipValidationResult(
relation: Int,requestedOrigin: Uri,result: Boolean,extras: Bundle?
) {
customTabsIntent = CustomTabsIntent.Builder(session).build().apply {
this.intent.putExtra(
browser.EXTRA_HEADERS,Bundle().apply {
putString(
HEADER,DATA
)
}
)
}
}
}
private val connection: CustomTabsServiceConnection = object : CustomTabsServiceConnection() {
override fun onCustomTabsServiceConnected(
name: ComponentName,client: CustomTabsClient
) {
session = client.newSession(callback)
client.warmup(0)
val validated = session?.validateRelationship(
CustomTabsService.RELATION_HANDLE_ALL_URLS,Uri.parse(SERVER_URL),null
)
Log.i("customTabs","connection: isValidated = $validated")
}
override fun onServicedisconnected(componentName: ComponentName) {}
}
override fun onStart() {
super.onStart()
CustomTabsClient.bindCustomTabsService(
this,CustomTabsClient.getPackageName(
this,getCustomTabsPackages().map {
it.activityInfo.packageName
}
),connection
)
当我运行代码时,日志会在验证后返回
使用 customTab 授权
val configuration =authConfig(webPage)
val redirectUri = REDIRECT_URI
val request = AuthorizationRequest.Builder(
configuration,CLIENT_ID,CODE,redirectUri
).build()
try {
val postAuthorizationIntent = Intent(context,Activity::class.java).apply {
action = ACTION_AUTHORIZATION
}
val pendingIntent = PendingIntent.getActivity(context,postAuthorizationIntent,0)
authService.performAuthorizationRequest(request,pendingIntent,customTabsIntent ?: backupTabIntent)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)