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

Summary

Types

credentials()

@type credentials() :: %{
  client_id: String.t(),
  client_secret: String.t(),
  tenant_id: String.t()
}

token_provider()

@type token_provider() :: (credentials() -> String.t())

Functions

fetch_token!(map)

@spec fetch_token!(credentials()) :: String.t()

new(creds, token_provider \\ &fetch_token!/1)