This plugin is a wrapper for the Microsoft Authentication Library (MSAL) for Go library. It enables you to acquire security tokens to call protected APIs.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-msal
yum install halon-extras-msal
For the configuration schema, see msal.schema.json. Below is a sample configuration.
plugins:
- id: msal
config:
tenants:
- id: tenant1
type: public
client_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
authority: https://login.microsoftonline.com/organizations
scopes:
- https://outlook.office.com/SMTP.Send
cache_file: /tmp/msal_tenant1_cache.json
- id: tenant2
type: confidential
client_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
client_secret: xxxxx~xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxx
authority: https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
scopes:
- https://graph.microsoft.com/.default
cache_file: /tmp/msal_tenant2_cache.json
These functions needs to be imported from the extras://msal
module path.
Fetch an OAuth2 access token using the provided credentials.
Params
- id
string
- The ID of the tenant as configured insmtpd.yaml
- options
array
- Options array
The following options are available in the options array.
- username
string
- The username (Only applicable to tenants of typepublic
) - password
string
- The password (Only applicable to tenants of typepublic
)
Returns
A successful fetch will return an associative array with a result
key that contains the access token. On error an associative array with a error
key will be provided.
Example
import { msal } from "extras://msal";
echo msal("tenant1", ["username" => "foo", "password" => "bar"]);