Getting "invalid_grant" when validating the authorization code

Hi, everyone,


I'm trying to implement Sign in with Apple and it's been going fine until I tried to valiate the authorization code using the Web Service Endpoint – https://appleid.apple.com/auth/token.


The error I'm getting back from the request is invalid_grant.


I'm sending the following in the POST request to that URL:


code=the_auth_code_given_to_the_app_when_signing_in
client_secret=the_jwt_i_generated
client_id=com.my.app
grant_type=authorization_code


If I decode the client_secret jwt that I created, it looks like this, which is what the documentation says it should look like.


{
    "alg": "ES256",
    "kid": "ABC123DEFG"
}
{
    "iss": "DEF123GHIJ",
    "iat": 1437179036,
    "exp": 1493298100,
    "aud": "https://appleid.apple.com",
    "sub": "com.my.app"
}


Any ideas? Thanks in advance.

Replies

Hi,


I am facing the exact same problem. I am trying to integrate this in a Django project using this https://github.com/truffls/sign-in-with-apple-using-django, already asked this question there as well https://github.com/truffls/sign-in-with-apple-using-django/issues/2 .


Others are having the same problem - https://forums.developer.apple.com/thread/118135


I'll reply if i'll get it working.

Hello dragosc, did you find a solution? I have the same problem and followed the same tutorial.

Hi bro, did you find any solution? I have the same problem.
I have the same problem and followed the same tutorial. Did you find the solution?
I already test using nodejs, .net core, insomnia and curl.