I am new to sign in wtih apple. When I trying to call sign in method, it will show a popup window, and show me the invalid_client error, here is my steps:
- create app id: com.yuhan.test.app

- create service id: com.yuhan.test.service

- configure my domain and returnURLs
domain: tts.perterpon.com
returnURL: https://tts.perterpon.com/login

- create keys for sign in with apple.

- code html, you can visit it here: https://tts.perterpon.com/login.html
Does anybody has some ideas? Thank you so so so much.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Apple Login</title>
</head>
<body>
<script type="text/javascript"
src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
<div id="appleid-signin"
data-color="black"
data-border="true"
data-type="sign in"></div>
<script type="text/javascript">
AppleID.auth.init({
clientId: 'com.yuhan.test.service',
scope: 'name email',
redirectURI: 'https://tts.perterpon.com/login',
usePopup: true
});
const buttonElementNew = document.getElementById('appleid-signin');
buttonElementNew.addEventListener('click', async () => {
try {
const data = await AppleID.auth.signIn()
console.log('Try/Catch Data', data.authorization.id_token);
const formData = new FormData();
formData.append("token", data.authorization.id_token);
await fetch("", {
method: "POST",
body: formData,
});
// Handle successful response.
} catch (error) {
// Handle error.
}
});
</script>
</body>
</html>
