Laravel, access smtp via modern authentication

FFor 1 Reputation point
2022-11-17T10:46:56.02+00:00

Hello,I have an application that sends mail with a customer's microsoft365 account.
Up to now SMTP authentication has been used, now customer wants to switch to modern Authentication.
A new application on azure has been created, and I have been provided with Tenant ID,
Application ID and Secret.

From what I understand in order to keep logged in I need a refresh token, I have followed diffrent guides but I'm not able to generate it.

is it possible to generate a token for a SMTP resource?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,336 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 39,736 Reputation points
    2022-11-18T03:24:20.077+00:00

    Hi @FFor

    You can try using auth code flow to get an access token and a refresh token.

    1.Run the URL in the browser to get the authorization code.

    https://login.microsoftonline.com/{tenant id}/oauth2/v2.0/authorize?  
    client_id={client id}  
    &response_type=code  
    &redirect_uri={redirect url}  
    &response_mode=query  
    &scope=https://graph.microsoft.com/SMTP.Send offline_access  
    &state=12345  
    

    261680-image.png

    2.Use the authorization code to redeem an access token and a refresh token.

    261696-page16.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.