# 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") ?? "";
            });
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aptitude.gitbook.io/zaubercms/identity/external-authentication-providers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
