Msg.Client (msg v0.1.1)
Responsible for handling authentication and request setup for
interacting with the Microsoft Graph API using the req
and oauth2
libraries.
Example
creds = %{
client_id: "your-client-id",
client_secret: "your-client-secret",
tenant_id: "your-tenant-id"
}
client = Msg.Client.new(creds)
Req.get!(client, "/me")
# With custom token provider for testability
token_provider = fn creds -> "stub-token" end
client = Msg.Client.new(creds, token_provider)
References
- Microsoft Graph REST API: https://learn.microsoft.com/en-us/graph/api/overview
- OAuth2 client credentials: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
Summary
Types
@type token_provider() :: (credentials() -> String.t())
Functions
@spec fetch_token!(credentials()) :: String.t()
@spec new(credentials(), token_provider()) :: Req.Request.t()