Skip to main content

Social Login not possible

Provider  Error CodeLink to Description
apple Not able to get social provider access tokenApple: Generate Client Secret

Apple: Generate client secret

What is the privateKey?

Apple will generate a new private key for you and let you download it only once. Make sure you save this file, because you won’t be able to get it back again later! The file you download will end in .p8

  • From the sidebar, choose Keys then click on Add button, as shown below.
  • Give suitable name for your key and check the Sign In with Apple checkbox. Then click on the Configure button.
  • Give suitable name for your key and check the Sign In with Apple checkbox. Then click on the Configure button.
  • In the next step, review your key details and click on Register button.
  • Make note of the Key ID which is required to generate client secret. Click on Download button to download your private key.

1. To generate client secret, use the following node js script

const fs = require("fs");
const jwt = require("jsonwebtoken");

const privateKey = fs.readFileSync("AuthKey_2AKZJ3L7T5.p8").toString(); //your downloaded private key path

const jwtToken = jwt.sign({}, privateKey, {
algorithm: "ES256",
expiresIn: "150d",
audience: "https://appleid.apple.com",
subject: "de.cidaas.testservice", //your service id
issuer: "**********", //your 10-character Team ID which you obtained during app id creation
header: {
alg: "ES256",
kid: "2AKZJ3L7T5" //your Key ID which you obtained during private key creation
}
});
console.log("secret:", jwtToken, "\n");

If you run this script, you will get your client secret, as shown below. Make note of this client secret.

secret: eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjlWUlVCQTRaNDgifQ.eyJpYXQiOjE1ODg2NzY1NjIsImV4cCI6MTYwMTYzNjU2MiwiYXVkIjoiaHR0cHM6Ly9hcHBsZWlkLmFwcGxlLmNvbSIsImlzcyI6IkJXTU03MlE1TTYiLCJzdWIiOiJkZS5jaWRhYXMudGVzdC1jZGMtcHJvZC1zZXJ2aWNlIn0.XPtxASA__aRBvz1rUfokMVbyZi_OVYQKQy9zyFrtmtNLzkzzvFmJbdQ09x5B4l9K9TOYP8HSWVBuQRNtn5Xc0Q