Providers icon indicating copy to clipboard operation
Providers copied to clipboard

Apple provider invalid_client

Open juggle-ninja opened this issue 1 year ago • 4 comments

When I try to use: Socialite::driver('apple')->stateless()->user() inside the callback function, I encounter an error: invalid_client.

The root cause is in the method: $response = $this->getAccessTokenResponse($this->getCode()); This method makes a Guzzle POST request to the /auth/token endpoint without including the required header 'Content-Type: application/x-www-form-urlencoded'. However, this header is required for the endpoint to process the request correctly.

juggle-ninja avatar Dec 03 '24 00:12 juggle-ninja

Same issue

Client error: `POST https://appleid.apple.com/auth/token` resulted in a `400 Bad Request` response:

{"error":"invalid_client"}

Also, it should be a GET request but doesn't work with GET request as it shows Method Not allowed

xcode-it avatar Dec 03 '24 08:12 xcode-it

@xcode-it , my initial assumption was incorrect. In my case, the issue was related to the use of the firebase/php-jwt package, which was generating an invalid JWT token. After switching to the lcobucci/jwt package, the problem was resolved.

juggle-ninja avatar Dec 03 '24 09:12 juggle-ninja

@xcode-it Tks for the tip, with your comment I was able to search and find a solution.

I had the same problem, in the past, i was created a token using the rb script, now I changed to a dinamyc and automatic way to generate the apple tokens , I used this article

vagkaefer avatar Mar 13 '25 21:03 vagkaefer

I have created a PR for this: https://github.com/SocialiteProviders/Providers/pull/1019

hamrak avatar Apr 30 '25 17:04 hamrak

Is this issue fixed? I am still getting this issue even after using new valid apple_id and client_secret. Please advise

jishnubmc avatar Jun 20 '25 05:06 jishnubmc

Is this issue fixed? I am still getting this issue even after using new valid apple_id and client_secret. Please advise

not solved. use another package for creating the token.

lucianodigital2b avatar Jun 21 '25 01:06 lucianodigital2b

PR above is merged.

atymic avatar Jun 28 '25 23:06 atymic