如何将 auth 与 CognitoUserSession 和 ApiClientFactory 一起使用?

How to use auth with CognitoUserSession and ApiClientFactory?

我正在尝试针对 Amazon Cognito Api 进行身份验证,但它不起作用...


正在创建一个 CognitoUserPool 用于注册和签到作品。但是如何从这里开始呢?

onSuccess(cognitoUserSession: CognitoUserSession) 中给我一个会话,我可以从中得到一个 jwtToken (userSession.accessToken.jwtToken).

如何结合Api因子使用会话?

val api: DevetrackcommercialplaygroundClient = ApiClientFactory()
            .apiKey(apiKey)
            .build(Client::class.java)

        val get= api.getFoo("id") // no auth; works
        val post = api.postBar("id", something) // has auth; doesn't work

总是给我 401。两者,如果我将 apiKey 设置为 api 键,如果我将它设置为 jwtToken.

那么如何结合使用 CognitoUserSessionApiClientFactory

似乎 A​​piGateway 并不是真的要与 user pools 一起使用,因为整个请求需要手动创建而不需要任何来自 sdk 的帮助 - 响应也是如此。
参见 https://github.com/aws-amplify/aws-sdk-android/issues/767

也许这会在未来的某个时候改变:

I agree with you that the Auth integration with API Gateway is not developer friendly and easy to use. We will take this feedback to the team to investigate on how to improve this integration. - kvasukib