# `Assent.Strategy.AzureAD`
[🔗](https://github.com/pow-auth/assent/blob/v0.4.0/lib/assent/strategies/azure_ad.ex#L1)

Azure Active Directory OpenID Connect strategy.

## Configuration

  * `:tenant_id` - the tenant identifier, optional, defaults to `common`.
    May be a directory ID, verified domain, or one of `common`,
    `organizations`, or `consumers`.

  * `:base_url` - the Microsoft identity platform issuer, optional, defaults
    to `https://login.microsoftonline.com/{tenant_id}/v2.0`

See `Assent.Strategy.OIDC` for more.

## Usage

    config = [
      client_id: "REPLACE_WITH_CLIENT_ID",
      client_secret: "REPLACE_WITH_CLIENT_SECRET",
      redirect_uri: "http://localhost:4000/auth/callback"
    ]

A tenant identifier can be set to limit which users can get access:

    config = [
      client_id: "REPLACE_WITH_CLIENT_ID",
      client_secret: "REPLACE_WITH_CLIENT_SECRET",
      tenant_id: "REPLACE_WITH_TENANT_ID",
      redirect_uri: "http://localhost:4000/auth/callback"
    ]

## Setting up Azure AD

Login to Azure, and [set up a new
application](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app):

* The callback URL should be added to "Redirect URI" for the application.
* `client_id` is the "Application ID".

# `authorize_url`

```elixir
@spec authorize_url(Keyword.t()) :: Assent.Strategy.OIDC.on_authorize_url()
```

Generates an OpenID Connect authorization URL.

# `callback`

```elixir
@spec callback(Keyword.t(), map()) :: Assent.Strategy.OIDC.on_callback()
```

Handles an OpenID Connect callback.

# `fetch_user`

```elixir
@spec fetch_user(Keyword.t(), map()) :: {:ok, map()} | {:error, term()}
```

Fetches user data from an ID Token or the UserInfo endpoint.

# `normalize`

Returns user claims without provider-specific normalization.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
