This repository contains a sample implementation of Sign in with Apple for ASP.NET Core written in C#.
Sign in with Apple is a way of allowing users of websites to sign in using their Apple ID.
This example integration shows a minimal sample of how to integrate Sign in with Apple a website to authenticate a user using their Apple ID and retrieve their email address (or a relay address to it) and their name.
To setup the repository to run the sample, perform the steps below:
- Install the .NET SDK, Visual Studio or Visual Studio Code version compatible with .NET 7.
- Fork this repository.
- Clone the repository from your fork to your local machine:
git clone https://github.com/{username}/SignInWithAppleSample.git
- Follow the steps to obtain your Client ID, Private Key, Key ID and Domain Verification file, if you do not already have them.
- Place the Domain Verification file (
apple-developer-domain-association.txt
) in thesrc\SignInWithApple\wwwroot\.well-known
folder. - Either add your
.p8
file contining the private key to generate the client secret to the root of the application insrc\SignInWithApple
(but not in thewwwroot
folder), or use some other mechanism, such as loading it from a blob storage account. - Update the favicon (
src\SignInWithApple\wwwroot\favicon.ico
) to your own design. - Configure the following settings as appropriate in either your environment variables or in
src\SignInWithApple\appsettings.json
:AppleClientId
AppleKeyId
AppleTeamId
- Deploy the application to the hosting environment for the domain where you wish to use Sign in with Apple.
- Verify the domain in the Apple Developer Portal.
You should now be able to sign in with your Apple ID in the deployed application.
You should be able to debug the application in Visual Studio Code or Visual Studio 2022 (17.3 or later).
If you are deploying the sample application to a Microsoft Azure App Service Web App, you will need to make the following configuration changes to your Web App for the sample application to run correctly:
ℹ️ The Free and Shared pricing tiers do not support features required to load the private key. See the Azure App Service documentation for the the other available pricing tiers.
- Navigate to the Application settings tab of your Web App and add the following settings:
WEBSITE_LOAD_USER_PROFILE
to a value of1
.- Save the changes.
- Ensure the hostname you are using (either
{yourappname}.azurewebsites.net
or a custom hostname that you have set up) has been added in the Apple Developer portal to your service id and you've added the Apple Developer domain validation file as described in the Setup section above.
Any feedback or issues can be added to the issues for this project in GitHub.
This project is licensed under the Apache 2.0 license.