英文:
invalid_client when requesting Amazon Cognito token with code from java spring back end
问题
我在运行以下代码时遇到了{"error":"invalid_client"}错误:
    public static HttpResponse<String> getAuthToken(@NonNull final String redirectUri, @NonNull final String code) {
        return Unirest.post("https://<myUrl>/oauth2/token")
                .header("content-type", "application/x-www-form-urlencoded")
                .body("grant_type=authorization_code" +
                        "&client_id=" + CognitoConstants.COGNIITO_CLIENT_ID +
                        "&redirect_uri=" + redirectUri +
                        "&code=" + code)
                .asString();
    }
代码看起来是正确的,客户端 ID 也是正确的。
如果您知道从 Cognito 获取适当的令牌的更好方法,请告诉我。他们的文档对于 OAuth2 初学者来说并没有解释得很清楚。
谢谢 ![]()
英文:
I get {"error":"invalid_client"} error when I'm running this:
    public static HttpResponse<String> getAuthToken(@NonNull final String redirectUri, @NonNull final String code) {
        return Unirest.post("https://<myUrl>/oauth2/token")
                .header("content-type", "application/x-www-form-urlencoded")
                .body("grant_type=authorization_code" +
                        "&client_id=" + CognitoConstants.COGNIITO_CLIENT_ID +
                        "&redirect_uri=" + redirectUri +
                        "&code=" + code)
                .asString();
    }
the code seems to be correct, so as Client id.
Please, if you know a better way to Get a proper token from Cognito - tell me. Their documentation doesn't exactly explain anything for a noob in Oauth2
Thank you ![]()
答案1
得分: 0
已解决,需要在64位客户端:密钥中再添加一个编码后的标头。
英文:
Solved, needed to have another header with encoded in 64bit client:secret
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论