title: Oauth2 apple signin on php laravel
body: <p>I'm still a newbie and want to ask about the task I'm working on,
  in this case I'm making authentication using oauth2 to be able to access apple api,
  but i have an error when signin using apple, invalid_client appears,
  for invalid_client error, I've done the following way:</p>
  
  <ol>
  <li>check the client_id used in the http request (doubts) (i've try by changing client_id)</li>
  <li>adjust the jwt header and jwt payload to the parameters requirements (checked)</li>
  <li>and check the JWT signature (checked)</li>
  </ol>
  
  <p>of the three steps that I tried, I felt doubt in the script authentication or client id</p>
  
  <p>please tell me where my fault is in the client_id naming or in the script section 
  thank you for the help, sorry for my bad english here I include the script that I use</p>
  
  <p>``</p>
  
  <pre><code>    $provider = new Apple([
          'clientId'      =&gt;  'com.example.example',
          'teamId'        =&gt;  'apple-team-id',
          'keyFileId'     =&gt;  'apple-key-file-id',
          'keyFilePath'   =&gt;  storage_path('apple-key-file-path'),
          'redirectUri'   =&gt;  'http://localhost:8000/Store/Gold_Store/GoldStore-create',
      ]);
  
      if(!isset($_POST['code'])){
  
          //jika kita tidak mempunyai authorization code
          $authUrl = $provider-&gt;getAuthorizationUrl();
          $_SESSION['oauth2state'] = $provider-&gt;getState();
          header('Location: '.$authUrl);
  
          exit;
  
      //check given state against previously stored one to mitigate CSRF attack
      } elseif (empty($_POST['state']) || ($_POST['state'] !== $_SESSION['oauth2state'])) {
  
          unset($_SESSION['oauth2state']);
          exit('Invalid state');
  
      }else{
          //try to get access token(using the authorization code grant)
          $token = $provider-&gt;getAccessToken('authorization_code', [
              'code' =&gt; $_POST['code']
          ]);
  
          //Optional: Now u have a token u can look up a user profile data
          try {
              //we got an access token, lets now get the user's detail
              $user = $provider-&gt;getResourceOwner($token);
  
              //use these details to create a new profile
              printf('hello %s!', $user-&gt;getFirstName());
  
              //refresh token
              $refreshToken = $token-&gt;getRefreshToken();
              $refreshTokenExpiration = $token-&gt;getRefreshTokenExpires();
  
          } catch (Exception $e) {
              //Failed to get user details
              exit(':-(');
          }
  
          //use this to interact with an API on the users behalf
          echo $token-&gt;getToken();
      }
  </code></pre>
  
  <p>this is my json result</p>
  
  <p>``{
      "error": "invalid_client"
  }</p>