appAuth-android 和带有数字资产链接的自定义标头

问题描述

我正在使用 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...