Mailozaurr can acquire delegated Microsoft Graph tokens using additional OAuth flows.
Use Connect-EmailGraph with the -DeviceCode switch to sign in with a device code. Provide the application ID, tenant ID and scopes.
$scopes = @('Mail.ReadWrite','Mail.Send')
$graph = Connect-EmailGraph -ClientId '<app id>' -DirectoryId '<tenant id>' -DeviceCode -Scopes $scopesFollow the instructions printed on the console to complete authentication.
If you already have a user access token, exchange it for Microsoft Graph scopes using -OnBehalfOfToken.
$token = Get-Content -Raw '.\UserToken.txt'
$graph = Connect-EmailGraph -ClientId '<app id>' -ClientSecret '<secret>' -DirectoryId '<tenant id>' `
-OnBehalfOfToken $token -Scopes $scopesBoth methods return a GraphConnectionInfo object with the OAuth credential available in the OAuthCredential property.