> For the complete documentation index, see [llms.txt](https://aptitude.gitbook.io/zaubercms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aptitude.gitbook.io/zaubercms/identity/external-authentication-providers.md).

# External Authentication Providers

As ZauberCMS uses identity you can use the external providers from Microsoft to allow registration and login using the external providers.

{% embed url="<https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/?view=aspnetcore-8.0&tabs=visual-studio>" %}
Link to the docs on the Microsoft website
{% endembed %}

We have included Facebook, Google & Microsoft out of the box, you just need to put your credentials in the appSettings and they will automatically show on the login and registration pages

```json
"ExternalProviders": {
  "Google": {
    "ClientId": "",
    "ClientSecret": ""
  },
  "Facebook": {
    "AppId": "",
    "AppSecret": ""
  },
  "Microsoft": {
    "ClientId": "",
    "ClientSecret": ""
  }
}
```

Adding New External Authentication Providers

If you want to add a new external provider, you need to Implement&#x20;

```
IExternalAuthenticationProvider
```

And you will need to reference the Nuget package from microsoft or write your own code to handle the provider. Below is an example of adding the Microsoft provider using the IExternalAuthenticationProvider

```csharp
public class MicrosoftAuthentication : IExternalAuthenticationProvider
{
    public void Add(IServiceCollection servicesCollection, AuthenticationBuilder authenticationBuilder, IConfiguration configuration)
    {
        var microsoftId = configuration.GetValue<string>("Zauber:Identity:ExternalProviders:Microsoft:ClientId");
        if (!microsoftId.IsNullOrWhiteSpace())
        {
            // https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins?view=aspnetcore-5.0
            authenticationBuilder.AddMicrosoftAccount(microsoftOptions =>
            {
                microsoftOptions.ClientId = microsoftId;
                microsoftOptions.ClientSecret = configuration.GetValue<string>("Zauber:Identity:ExternalProviders:Microsoft:ClientSecret") ?? "";
            });
        }
    }
}
```
