View Source Momento.Auth.CredentialProvider (Momento Elixir SDK v0.8.0)

Handles decoding and managing Momento authentication credentials.

Link to this section Summary

Functions

Constructs a credential provider from the given v2 api key and endpoint.

Parses the given disposable token into a credential provider.

Fetches the given environment variable and parses it into a credential.

Fetches the Momento service endpoint and v2 api key stored in the given environment variables in order to construct a credential provider.

Parses the given string into a credential.

Link to this section Types

@opaque t()

Link to this section Functions

Link to this function

auth_token(credential_provider)

View Source
@spec auth_token(credential_provider :: t()) :: String.t()
Link to this function

cache_endpoint(credential_provider)

View Source
@spec cache_endpoint(credential_provider :: t()) :: String.t()
Link to this function

control_endpoint(credential_provider)

View Source
@spec control_endpoint(credential_provider :: t()) :: String.t()
Link to this function

from_api_key_v2!(token, endpoint)

View Source
@spec from_api_key_v2!(String.t(), String.t()) :: t()

Constructs a credential provider from the given v2 api key and endpoint.

Returns the credential or raises an exception.

examples

Examples

iex> valid_token = "valid_token" # This should be a valid Momento v2 api key.
iex> Momento.Auth.CredentialProvider.from_api_key_v2!(valid_token, "momento.endpoint.here")
%Momento.Auth.CredentialProvider{}
Link to this function

from_disposable_token!(token)

View Source
@spec from_disposable_token!(String.t()) :: t()

Parses the given disposable token into a credential provider.

Returns the credential provider or raises an exception.

examples

Examples

iex> valid_token = "valid_token" # This should be a valid Momento auth token.
iex> Momento.Auth.CredentialProvider.from_disposable_token!(valid_token)
%Momento.Auth.CredentialProvider{}
Link to this function

from_env_var!(env_var, opts \\ [])

View Source
This function is deprecated. Use from_env_var_v2!/2 instead.
@spec from_env_var!(
  env_var :: String.t(),
  opts :: [control_endpoint: String.t(), cache_endpoint: String.t()]
) :: t()

Fetches the given environment variable and parses it into a credential.

Returns the credential or raises an exception.

Supply control_endpoint or cache_endpoint in the options to override them.

examples

Examples

iex> Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
%Momento.Auth.CredentialProvider{}
Link to this function

from_env_var_v2!(api_key_env_var \\ "MOMENTO_API_KEY", endpoint_env_var \\ "MOMENTO_ENDPOINT")

View Source
@spec from_env_var_v2!(
  api_key_env_var :: String.t(),
  endpoint_env_var :: String.t()
) :: t()

Fetches the Momento service endpoint and v2 api key stored in the given environment variables in order to construct a credential provider.

Returns the credential provider or raises an exception.

examples

Examples

iex> Momento.Auth.CredentialProvider.from_env_var_v2!("MOMENTO_API_KEY", "MOMENTO_ENDPOINT")
%Momento.Auth.CredentialProvider{}
Link to this function

from_string!(token, opts \\ [])

View Source
@spec from_string!(
  String.t(),
  keyword()
) :: t()

Parses the given string into a credential.

Returns the credential or raises an exception.

Supply control_endpoint or cache_endpoint in the options to override them.

examples

Examples

iex> valid_token = "valid_token" # This should be a valid Momento auth token.
iex> Momento.Auth.Credential.from_string!(valid_token)
%Momento.Auth.Credential{}