Skip to main content
Version: v0.15

Apple

In this tutorial, we'll set up Apple authentication for Conduit.
Apple authentication is a way for users to sign in to your app using their Apple ID. Apple authentication provides a secure and private way for users to sign in to your app.

Prerequisites

This provider is a little different from the others.
You'll need to have an Apple Developer account and an Apple App ID.

  • Apple App ID
  • Apple Developer Account

Create an Apple App ID

  1. Go to Apple Developer and sign in with your Apple ID.
  2. Click on Identifiers and then App IDs.
  3. Click on the + button to create a new App ID.
  4. Enter a description for your App ID and select Sign in with Apple as the primary App ID.
  5. Click on Continue and then Register.
  6. Click on the Edit button next to your App ID.
  7. Click on Configure next to the Sign in with Apple capability.
  8. Click on Enable as a primary App ID.
  9. Click on Save and then Done.

Create an Apple Service ID

  1. Go to Apple Developer and sign in with your Apple ID.
  2. Click on Identifiers and then Services IDs.
  3. Click on the + button to create a new Service ID.
  4. Enter a description for your Service ID and select Sign in with Apple as the primary Service ID.
  5. Click on Continue and then Register.
  6. Click on the Edit button next to your Service ID.
  7. Click on Configure next to the Sign in with Apple capability.
  8. Click on Enable as a primary Service ID.
  9. Click on Save and then Done.

Create an Apple Private Key

  1. Go to Apple Developer and sign in with your Apple ID.
  2. Click on Keys and then +.
  3. Enter a description for your key and click on Configure.
  4. Select Sign in with Apple and click on Continue.
  5. Click on Register.
  6. Click on the Download button next to your key.
  7. Click on Done.

Create an Apple Team ID

  1. Go to Apple Developer and sign in with your Apple ID.
  2. Click on Membership and then View Details.
  3. Copy your Team ID.

Create an Apple Client ID

  1. Go to Apple Developer and sign in with your Apple ID.
  2. Click on Identifiers and then App IDs.
  3. Click on the Edit button next to your App ID.
  4. Click on Configure next to the Sign in with Apple capability.
  5. Copy your Client ID.

Setting up the configuration

NOTE
Do not forget to configure the Apple provider through the Admin Panel.
Go to the Authentication -> SIGN IN METHODS and select the Apple provider.
Then, fill the required fields with the values you got from the previous steps.

  • clientId - The client id that you created in the previous step.
  • redirect_uri - The uri that the user will be redirected to, on successful Apple login, when using the redirect method.
  • privateKey - The private key that you created in the previous step.
  • teamId - The team id that you copied in the previous step.
  • keyId - The private key id that you created in the previous step.

Enable Apple Provider

Enable Apple Provider and click on Save.

Authenticate with Apple

Now that you have configured the Apple provider, you can authenticate with it.

Redirect Method

The redirect method is the easiest way to authenticate with Apple.
It will redirect the user to the Apple login page, where they can sign in with their Apple ID.
After signing in, the user will be redirected back to your app.

To begin authenticating with Apple you request a redirect url with the proper scopes

Request
curl --location --request GET 'http://localhost:3000/authentication/apple'
Response
{
"result": "https://appleid.apple.com/auth/authorize?client_id=io.conduit.app&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauthentication%2Fapple%2Fcallback&response_type=code%20id_token&response_mode=form_post&scope=name%20email&state=eyJpZCI6IjYzNjNjZGNkMDhkNTU2MDk1NmM4MGQ4OSIsImlhdCI6MTY2OTIxMDM1MywiZXhwIjoxNjY5MjgyMzUzfQ.TyvHCuyDKLiKFoEpaXRdbYoFwrzDlFiW4VdUVQJdf7U&nonce=eyJpZCI6IjYzNjNjZGNkMDhkNTU2MDk1NmM4MGQ4OSIsImlhdCI6MTY2OTIxMDM1MywiZXhwIjoxNjY5MjgyMzUzfQ.TyvHCuyDKLiKFoEpaXRdbYoFwrzDlFiW4VdUVQJdf7U"
}

Open a browser and navigate to the url returned to you from Conduit.
Now the /hook/authentication route has been triggered.
Once your browser has been redirected, your authentication has been completed.