Skip to content

Update for Andres. Added generating Key ID for Client Secret #9709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion articles/connections/social/apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -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') %>
43 changes: 43 additions & 0 deletions snippets/social/apple/4.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```