RingCentral.OAuth (RingCentral v0.2.0) View Source

The main module for the Authorization flow

Link to this section Summary

Functions

Get the URL for initializing the OAuth 2.0 authorizaiton flow.

Get the access token and refresh token.

Revokes access/refresh token.

Link to this section Functions

Link to this function

authorize(ringcentral, params \\ %{})

View Source

Specs

authorize(RingCentral.t(), map()) ::
  {:error, RingCentral.Error.t()} | {:ok, String.t()}

Get the URL for initializing the OAuth 2.0 authorizaiton flow.

params is a map contains the options described in the official documentation

Example

ringcentral = %RingCentral{
  client_id: "the-client-id",
  client_secret: "the-client-secret",
  http_client: RingCentral.HTTPClient.DefaultClient,
  server_url: "https://platform.ringcentral.com",
  token_info: nil
}

{:ok, authorization_url} = RingCentral.OAuth.authorize(ringcentral, %{
  response_type: "code",
  redirect_uri: "https://ringcentral-elixir.test"
})
# {:ok, "https://service.ringcentral.com/..."}
Link to this function

get_token(ringcentral, params \\ %{})

View Source

Specs

get_token(RingCentral.t(), map()) ::
  {:error, RingCentral.Error.t()} | {:ok, String.t()}

Get the access token and refresh token.

params is a map contains the options described in the official documentation

Example

ringcentral = %RingCentral{
  client_id: "the-client-id",
  client_secret: "the-client-secret",
  http_client: RingCentral.HTTPClient.DefaultClient,
  server_url: "https://platform.ringcentral.com",
  token_info: nil
}

{:ok, token_info} = RingCentral.OAuth.get_token(ringcentral, %{
  grant_type: "authorization_code",
  code: "U0pDMDFQMDRQQVMwMnxBQUFGTVUyYURGYi0wUEhEZ2VLeGFiamFvZlNMQlZ5TExBUHBlZVpTSVlhWk",
  redirect_uri: "https://ringcentral-elixir.test"
})
# {:ok, %{"access_token": "...", "token_type": "bearer", "refresh_token": "..."}}
Link to this function

revoke_token(ringcentral, token)

View Source

Specs

revoke_token(RingCentral.t(), String.t()) ::
  {:error, RingCentral.Error.t()} | :ok

Revokes access/refresh token.

token is the active access or refresh token to be revoked, see the official documentation for more information.

Example

ringcentral = %RingCentral{
  client_id: "the-client-id",
  client_secret: "the-client-secret",
  http_client: RingCentral.HTTPClient.DefaultClient,
  server_url: "https://platform.ringcentral.com",
  token_info: nil
}

RingCentral.OAuth.revoke_token(ringcentral, "U0pDMDFQMDFKV1MwMXwJ_W7L1fG4eGXBW9Pp-otywzriCw")
# :ok