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);
?>