Box v0.2.3 BoxOAuth2 View Source
OAuth2 authentication layer for unofficial Box SDK.
Configuration
You need to set the required credentials in your application configuration. Typically this is done in config/config.exs or a similar file. For example:
config :box,
client_id: "abc12",
enterprise_id: "123",
public_key_id: "abc123",
client_secret: "secret",
private_key_path: "config/key.pem",
private_key_password: System.get_env("PRIVATE_KEY_PASSWORD")
Usage
Use new to fetch the application configuration and then login.
{:ok, auth} = BoxOAuth2.new()
{:ok, auth} = BoxOAuth2.login(auth)
Link to this section Summary
Functions
Downscope token creates a token with limited access to a particular file or folder.
Login does an initial login or refreshes the OAuth token if it expired. If the existing access token is still valid, login won't request a new token.
New BoxAuth2 structure configured from the application environment.
Link to this section Types
t()
View Source
t() :: %BoxOAuth2{
authentication_url: String.t(),
client: Tesla.Client.t(),
client_id: String.t(),
client_secret: String.t(),
enterprise_id: String.t(),
expires_after: DateTime.t(),
private_key: String.t(),
public_key_id: String.t(),
token: String.t()
}
t() :: %BoxOAuth2{
authentication_url: String.t(),
client: Tesla.Client.t(),
client_id: String.t(),
client_secret: String.t(),
enterprise_id: String.t(),
expires_after: DateTime.t(),
private_key: String.t(),
public_key_id: String.t(),
token: String.t()
}
Link to this section Functions
downscope_token(auth, scopes, resource)
View Source
downscope_token(BoxOAuth2.t(), list(), String.t()) :: tuple()
downscope_token(BoxOAuth2.t(), list(), String.t()) :: tuple()
Downscope token creates a token with limited access to a particular file or folder.
scopes = ['base_upload']
resource = "https://api.box.com/2.0/folders/75453696283"
{:ok, response} = BoxOAuth2.downscope_token(auth, scopes, resource)
login(auth)
View Source
login(BoxOAuth2.t()) :: tuple()
login(BoxOAuth2.t()) :: tuple()
Login does an initial login or refreshes the OAuth token if it expired. If the existing access token is still valid, login won't request a new token.
new(base_url \\ "https://api.box.com/oauth2/token") View Source
New BoxAuth2 structure configured from the application environment.