When setting up Apple Login, it succeeds in the local environment, but fails with Auth0 connections

I am currently configuring the Social Connections > Apple settings. I have performed the configurations on Apple Developer and initially conducted a connection test in a local environment. (The PHP code below has successfully connected.)

Having confirmed the connection, I performed similar settings on Auth0, but an error occurs. (invalid_request / the connection is not enabled)

Could it be that I’ve configured the wrong settings?

Local
------------
/Root
 ┣ index.php
 ┗ client_secret.php
 

▼index.php
  <?php
    session_start();
    $client_id = '【client_id】';
    $client_secret = shell_exec('php client_secret.php');
    $redirect_uri = 'https://【tenant-domain】.auth0.com/login/callback';
    $_SESSION['state'] = bin2hex(random_bytes(5));
    $authorize_url = 'https://appleid.apple.com/auth/authorize'.'?'.http_build_query([
      'response_type' => 'code',
      'response_mode' => 'form_post',
      'client_id' => $client_id,
      'redirect_uri' => $redirect_uri,
      'state' => $_SESSION['state'],
      'scope' => 'name email',
    ]);
    echo '<a href="'.$authorize_url.'">Sign In with Apple</a>';


▼client_secret.php
  <?php
    require '../vendor/autoload.php';
    use \Firebase\JWT\JWT;
    $teamId = '【teamId】';
    $keyId = '【keyId】';
    $sub = '【client_id】';
    $aud = 'https://appleid.apple.com';
    $iat = strtotime('now');
    $exp = strtotime('+60days');
    $keyContent = file_get_contents('../key.txt'); // ClientSecretSigningKey
    echo JWT::encode([
        'iss' => $teamId,
        'iat' => $iat,
        'exp' => $exp,
        'aud' => $aud,
        'sub' => $sub,
    ], $keyContent, 'ES256', $keyId);
  ?>

Hi @masato,

Thanks for the question!

This error may indicate that the connection has not been enabled in your Auth0 Application Settings.

Please let me know if that doesn’t solve it and we can dig deeper.

Hope this helps!

1 Like

I can’t believe it! I thought the tests were independent!
When I activated the application and tested it, it worked without any issues.

You’ve been a great help. Thank you, dan.woda. :smile:

1 Like

Glad I could be of service! Have a nice day!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.