View Source oidcc_client_context (Oidcc v3.0.0-rc.5)
Client Configuration for authorization, token exchange and userinfo
For most projects, it makes sense to use oidcc_provider_configuration_worker
and the high-level interface of oidcc
. In that case direct usage of this module is not needed.
To use the record, import the definition:
-include_lib(["oidcc/include/oidcc_client_context.hrl"]).
Summary
Functions
Create Client Context from a oidcc_provider_configuration_worker
Create Client Context from a oidcc_provider_configuration_worker
Create Client Context manually
Create Client Context manually
Types
Link to this type
error/0
View Source (since 3.0.0 -------------------------------------------------------------------)-type error() :: provider_not_ready.
Link to this type
opts/0
View Source (since 3.0.0 -------------------------------------------------------------------)-type opts() :: #{client_jwks => jose_jwk:key()}.
Link to this type
t/0
View Source (since 3.0.0 -------------------------------------------------------------------)-type t() ::
#oidcc_client_context{provider_configuration :: oidcc_provider_configuration:t(),
jwks :: jose_jwk:key(),
client_id :: binary(),
client_secret :: binary(),
client_jwks :: jose_jwk:key() | none}.
Functions
Link to this function
from_configuration_worker(ProviderName, ClientId, ClientSecret)
View Source (since 3.0.0)-spec from_configuration_worker(ProviderName, ClientId, ClientSecret) -> {ok, t()} | {error, error()} when ProviderName :: gen_server:server_ref(), ClientId :: binary(), ClientSecret :: binary().
Create Client Context from a oidcc_provider_configuration_worker
from_configuration_worker/4
Link to this function
from_configuration_worker(ProviderName, ClientId, ClientSecret, Opts)
View Source (since 3.0.0)-spec from_configuration_worker(ProviderName, ClientId, ClientSecret, Opts) -> {ok, t()} | {error, error()} when ProviderName :: gen_server:server_ref(), ClientId :: binary(), ClientSecret :: binary(), Opts :: opts().
Create Client Context from a oidcc_provider_configuration_worker
Examples
{ok, Pid} =
oidcc_provider_configuration_worker:start_link(#{
issuer => <<"https://login.salesforce.com">>
}),
{ok, #oidcc_client_context{}} =
oidcc_client_context:from_configuration_worker(Pid,
<<"client_id">>,
<<"client_secret">>).
{ok, Pid} =
oidcc_provider_configuration_worker:start_link(#{
issuer => <<"https://login.salesforce.com">>,
name => {local, salesforce_provider}
}),
{ok, #oidcc_client_context{}} =
oidcc_client_context:from_configuration_worker($
salesforce_provider,
<<"client_id">>,
<<"client_secret">>,
#{client_jwks => jose_jwk:generate_key(16)}
).
Link to this function
from_manual(Configuration, Jwks, ClientId, ClientSecret)
View Source (since 3.0.0)-spec from_manual(Configuration, Jwks, ClientId, ClientSecret) -> t() when Configuration :: oidcc_provider_configuration:t(), Jwks :: jose_jwk:key(), ClientId :: binary(), ClientSecret :: binary().
Create Client Context manually
Seefrom_manual/5
Link to this function
from_manual(Configuration, Jwks, ClientId, ClientSecret, Opts)
View Source (since 3.0.0)-spec from_manual(Configuration, Jwks, ClientId, ClientSecret, Opts) -> t() when Configuration :: oidcc_provider_configuration:t(), Jwks :: jose_jwk:key(), ClientId :: binary(), ClientSecret :: binary(), Opts :: opts().
Create Client Context manually
Examples
{ok, Configuration} =
oidcc_provider_configuration:load_configuration(<<"https://login.salesforce.com">>,
[]),
#oidcc_provider_configuration{jwks_uri = JwksUri} = Configuration,
{ok, Jwks} = oidcc_provider_configuration:load_jwks(JwksUri, []).
#oidcc_client_context{} =
oidcc_client_context:from_manual(
Metdata,
Jwks,
<<"client_id">>,
<<"client_secret">>,
#{client_jwks => jose_jwk:generate_key(16)}
).