active-directory icon indicating copy to clipboard operation
active-directory copied to clipboard

How can I use the access token to call the the Microsoft graph api?

Open thebatmanreturns opened this issue 4 years ago • 1 comments

thebatmanreturns avatar May 16 '20 11:05 thebatmanreturns

Hi, I have a piece of code here:

$email = "{
    Message: {
    Subject: 'Sent using the Microsoft Graph REST API',
    Body: {
        ContentType: 'text',
        Content: 'This is the email body'
    },
    ToRecipients: [
        {
            EmailAddress: {
            Address: '[email protected]'
            }
        }
    ]
    }}";



$response = $client->request('POST', 'https://graph.microsoft.com/v1.0/me/sendMail', [
    'headers' => [
        'Authorization' => 'Bearer ' . $entity->getAccessToken(),
        'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true'
    ],
    'body' => $email
]);

How can I use the access_token token provided by the magium and send an email? Please let me know.

thebatmanreturns avatar May 16 '20 11:05 thebatmanreturns