# `Oidcc.Plug.Authorize`
[🔗](https://github.com/erlef/oidcc_plug/blob/989b809174070ef71c9dc545de149854f86d8f7c
/lib/oidcc/plug/authorize.ex#L1)

Initiate Code Flow Authorization Redirect

```elixir
defmodule SampleAppWeb.Router do
  use Phoenix.Router

  # ...

  forward "/oidcc/authorize", to: Oidcc.Plug.Authorize,
    init_opts: [
      provider: SampleApp.GoogleOpenIdConfigurationProvider,
      client_id: Application.compile_env!(:sample_app, [Oidcc.Plug.Authorize, :client_id]),
      client_secret: Application.compile_env!(:sample_app, [Oidcc.Plug.Authorize, :client_secret]),
      redirect_uri: "https://localhost:4000/oidcc/callback"
    ]
end
```

## Query Params

* `state` - State to relay to OpenID Provider. Commonly used for target redirect
  URL after authorization.
  Accessible through `Plug.Conn.private[Elixir.Oidcc.Plug.Authorize.State]` after `Oidcc.Plug.AuthorizationCallback`

# `opts`
*since 0.1.0* 

```elixir
@type opts() :: [
  scopes: :oidcc_scope.scopes(),
  redirect_uri: String.t() | (-&gt; String.t()) | (Plug.Conn.t() -&gt; String.t()),
  url_extension: :oidcc_http_util.query_params(),
  provider: GenServer.name() | nil,
  client_store: module() | nil,
  client_id: String.t() | (-&gt; String.t()) | (Plug.Conn.t() -&gt; String.t()) | nil,
  client_secret:
    String.t() | (-&gt; String.t()) | (Plug.Conn.t() -&gt; String.t()) | nil,
  client_context_opts:
    :oidcc_client_context.opts() | (-&gt; :oidcc_client_context.opts()) | nil,
  client_profile_opts: :oidcc_profile.opts()
]
```

Plug Configuration Options

## Options

* `scopes` - scopes to request
* `redirect_uri` - Where to redirect for callback
* `url_extension` - Custom query parameters to add to the redirect URI
* `provider` - name of the `Oidcc.ProviderConfiguration.Worker`
* `client_id` - OAuth Client ID to use for the introspection
* `client_secret` - OAuth Client Secret to use for the introspection
* `client_context_opts` - Options for Client Context Initialization
* `client_profile_opts` - Options for Client Context Profiles
* `client_store` - A module name that implements the `Oidcc.Plug.ClientStore` behaviour
  to fetch the client context from a store instead of using the `provider`, `client_id` and `client_secret`
  directly. This is useful for storing the client context in a database or other persistent
  storage.

---

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