diff --git a/articles/connections/social/apple.md b/articles/connections/social/apple.md index 0f807aeb82..203b14c489 100644 --- a/articles/connections/social/apple.md +++ b/articles/connections/social/apple.md @@ -24,4 +24,4 @@ useCase: <%= include('../../../snippets/social/apple/3') %> <%= include('../../../snippets/social/apple/4') %> <%= include('../../../snippets/social/apple/5') %> -<%= include('../../../snippets/social/apple/6') %> +<%= include('../../../snippets/social/apple/6') %> \ No newline at end of file diff --git a/snippets/social/apple/4.md b/snippets/social/apple/4.md index 6e3da6ca4e..58f084acba 100644 --- a/snippets/social/apple/4.md +++ b/snippets/social/apple/4.md @@ -13,3 +13,46 @@ Besides the standard social connection settings, the Apple social connection con |---------|-------------| | Team ID | ID of the organization Apple approved to receive their development kit. Developer accounts are associated with an approved team. You can find your Team ID in the Apple Developer Portal under **Membership Details**. | | Key ID | ID of the token signing key that Apple issued to allow your app to communicate with Apple Push Notifications (APNs). You can find your Key ID in the Apple Developer Portal under **Certificates, Identifiers & Profiles**. | + + +#### Set up your Client Secret Signing Key +1. Go to **Keys** under the **Certificates, Identifiers, & Profiles** section of your Apple developer dashboard. +2. Select the **blue plus icon** to add a new key. +3. Enter a **Key Name** and check the **Sign In with Apple** option. +4. Select **Configure** to make sure the **Choose a Primary App ID** field is filled with the correct App ID. +5. Select **Save**, **Continue**, and then **Register**. +6. On the page to which you're redirected after registering, make note of the Key ID. Then download the key. +7. Rename the key to `authkey.p8` +8. Click **Done** on the Apple Developer Portal and make a note of the Key ID. +9. Create a file called `generate-secret.js` inside the project root and add the following code: +``` +const jwt = require("jsonwebtoken"); +const fs = require("fs"); + +const privateKey = fs.readFileSync("./authkey.p8"); +const token = jwt.sign({}, privateKey, { + algorithm: "ES256", + expiresIn: "2 days", + audience: "https://appleid.apple.com", + issuer: "TEAM_ID", + subject: "com.brunokrebs.webapp", + keyid: "KEY_ID" +}); + +console.log("The token is:", token); +``` +::note +Replace `com.brunokrebs.webapp ` with the identifier for your Service ID and `TEAM_ID` with your specific Team ID. You can find these values in the Apple Developer Portal. Replace the `KEY_ID` with the Key ID you saved in Step 8. +:: +10. Generate a new token: +`node generate-secret.js` +The value the script outputs is the `CLIENT_SECRET` environment variable you must use. +11. Go to your server and stop the web application instance. +12. Enter the final environment values in the following commands: +``` +export CLIENT_ID=com.brunokrebs.webapp +export CLIENT_SECRET=eyJ...KsA +export CALLBACK=https://brunokrebs.com/callback + +npm start +``` \ No newline at end of file