internetdata_oauth (internetdata v1.6.1)

View Source

The OAuth device flow behind the oauth_* functions on internetdata.

No request made here carries the API key the client was built with, and a client built without one works exactly the same. Every answer is a map whose keys come from a fixed allowlist of atoms; members the server adds later are dropped rather than minted.

Summary

Types

device_authorization/0

-type device_authorization() ::
          #{device_code := binary(),
            user_code := binary(),
            verification_uri := binary(),
            verification_uri_complete => binary(),
            expires_in := integer(),
            interval := integer()}.

metadata/0

-type metadata() ::
          #{issuer := binary(),
            authorization_endpoint := binary(),
            token_endpoint := binary(),
            device_authorization_endpoint => binary(),
            revocation_endpoint => binary(),
            scopes_supported => [binary()],
            response_types_supported => [binary()],
            grant_types_supported => [binary()],
            code_challenge_methods_supported => [binary()],
            token_endpoint_auth_methods_supported => [binary()],
            authorization_response_iss_parameter_supported => boolean(),
            service_documentation => binary()}.

token_response/0

-type token_response() ::
          #{access_token := binary(),
            token_type := binary(),
            expires_in := integer(),
            refresh_token => binary(),
            scope => binary(),
            apikey_id => binary(),
            apikey => binary()}.

Functions

device_authorization(Client, ClientId, Extra, Options)

-spec device_authorization(map(), binary(), [{binary(), binary()}], map()) ->
                              {ok, device_authorization()} | {error, internetdata_error:error()}.

exchange_device_code(Client, ClientId, DeviceCode, Options)

-spec exchange_device_code(map(), binary(), binary(), map()) ->
                              {ok, token_response()} | {error, internetdata_error:error()}.

exchange_refresh_token(Client, ClientId, RefreshToken, Options)

-spec exchange_refresh_token(map(), binary(), binary(), map()) ->
                                {ok, token_response()} | {error, internetdata_error:error()}.

metadata(Client, Options)

-spec metadata(map(), map()) -> {ok, metadata()} | {error, internetdata_error:error()}.

poll_device_token(Client, ClientId, Device, Options)

-spec poll_device_token(map(), binary(), device_authorization(), map()) ->
                           {ok, token_response()} | {error, internetdata_error:error()}.

revoke(Client, ClientId, Token, Options)

-spec revoke(map(), binary(), binary(), map()) -> ok | {error, internetdata_error:error()}.