View Source CastorEDC.Client (ExCastorEDC v0.2.0)

Container for authentication related values

If you plan to use https://data.castoredc.com/ as an endpoint then you can use new/2

client = Client.new("<client id>", "<client secret>")

When your study is located in a different region then you can use new/3

client = Client.new("<client id>", "<client secret>", "https://<domain>/")

The clients can then be passed to CastorEDC.authenticate/1 for an access token.

Depending on whether you have a long-lived access token you can use either access_token/1 or access_token/2 and pass in an access token directly allowing you to skip the authentication step.

  client = Client.access_token("<access token>")

Link to this section Summary

Functions

If you already have an access token you can use this function to pass it in directly allowing you to skip the authentication step.

You can get your client id and secret from the account settings page after logging in over at https://data.castoredc.com/ or the region that your studies reside at.

This is an internal function that will add the access token after the authentication step.

Link to this section Types

@type t() :: %CastorEDC.Client{
  access_token: nil | String.t(),
  client_id: nil | uuid(),
  client_secret: nil | String.t(),
  endpoint: url(),
  grant_type: String.t(),
  scope: String.t()
}
@type url() :: String.t()
@type uuid() :: String.t()

Link to this section Functions

Link to this function

access_token(access_token)

View Source
@spec access_token(String.t()) :: t()

If you already have an access token you can use this function to pass it in directly allowing you to skip the authentication step.

client = Client.access_token("<access token>")

or access_token/2 when your studies are hosted, for example, in Australia

client = Client.access_token("<access token>", "https://au.castoredc.com/")
Link to this function

access_token(access_token, endpoint)

View Source
@spec access_token(String.t(), url()) :: t()
Link to this function

new(client_id, client_secret)

View Source
@spec new(uuid(), String.t()) :: t()

You can get your client id and secret from the account settings page after logging in over at https://data.castoredc.com/ or the region that your studies reside at.

client = Client.new("<client id>", "<client secret>")

Use new/3 if your studies are hosted, for example, in the US.

client = Client.new("<client id>", "<client secret>", "https://us.castoredc.com/")
Link to this function

new(client_id, client_secret, endpoint)

View Source
@spec new(uuid(), String.t(), url()) :: t()
Link to this function

put_token(client, access_token)

View Source
@spec put_token(t(), String.t()) :: t()

This is an internal function that will add the access token after the authentication step.