首页 > 解决方案 > Tapkey 令牌交换成功,但在尝试登录时收到 400 Bad Request

问题描述

我已成功使用 Tapkey 令牌交换端点将 Firebase 令牌交换为 Tapkey 令牌,但随后调用登录时出错。

交换令牌时,我被要求提供以下范围:

注册:手机读取:用户读取:IP:用户句柄:键

我的快速代码如下(基本上直接从文档中提取):

let authToken = ExchangeFirebaseTokenForTapkeyToken(firebaseToken);

if authToken == nil {
    return
}

// For testing purposes, normally this would be static and only built once
let serviceFactory = TKMServiceFactoryBuilder()
    .setTokenRefreshHandler(TapkeyTokenRefreshHandler())
    .build()

let userManager = serviceFactory.userManager

let result = userManager.logInAsync(accessToken: authToken!, cancellationToken: TKMCancellationTokens.None)

result.continueOnUi { (userId) -> Void in
    print(userId as Any)
}
.catchOnUi { (error) -> Void in
    print(error)
}
.conclude()

日志如下,如您所见,我收到Failed to authenticateAsync错误和 HTTP 400 响应。

2021-06-14 14:25:48.805135+0100 App[11940:234234] LogonManager: 开始认证

6 月 14 日 14:25:48 [11940]:LogonManager:开始身份验证

2021-06-14 14:25:48.805917+0100 App[11940:234234] NetTpkyMcRestLoggingAsyncHttpRequestExecutor:请求 POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' 开始。

6 月 14 日 14:25:48 [11940]:NetTpkyMcRestLoggingAsyncHttpRequestExecutor:请求 POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' 开始。

2021-06-14 14:25:49.464429+0100 App[11940:234234] NetTpkyMcRestLoggingAsyncHttpRequestExecutor:请求 POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' 完成代码659 毫秒后为 400。

6 月 14 日 14:25:49 [11940]:NetTpkyMcRestLoggingAsyncHttpRequestExecutor:请求 POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' 在 659 毫秒后使用代码 400 完成。

2021-06-14 14:25:49.476961+0100 应用程序 [11940:234234] AuthenticationManagerImpl:无法进行身份验证异步

如果我提供从 Token Exchange 端点返回的访问密钥以外的任何值,我会得到 401 Unauthorized(这是意料之中的)。

我已经尝试将此用户添加到门户,但我仍然遇到同样的问题。

还有什么我需要做的,或者我需要添加到我的 iOS 应用程序的任何额外配置吗?我已将我的配置与示例应用程序匹配(据我所知)无济于事。

谢谢

标签: iosauthenticationtapkey

解决方案


外部身份提供者的用户必须先注册才能登录。

您可以在此处找到详细信息: https ://developers.tapkey.io/api/authentication/identity_providers/#working-with-users

如果您的用例需要在登录时自动创建这些用户,请向 tapkey 支持发送请求,他们将为您启用此功能。


推荐阅读