I'm following this guide https://docs.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth and here's all the steps I've taken -
Note: I'm not posting my actual client id's, codes or secrets.
Step 1: Register an Azure app.
Account type: Accounts in this organizational directory only
Redirect URI: http://localhost (Web)
Created a client secret
Added SMTP.Send API permission
Step 2: Request an authorization code
https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
&redirect_uri=http://localhost
&response_mode=query
&scope=https://outlook.office.com/SMTP.Send
Step 3: Redeem the authorization code (!!! 793 characters long) for an access token using the client secret
curl -d "client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&scope=https://outlook.office.com/SMTP.Send
&code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
&redirect_uri=http://localhost
&grant_type=authorization_code
&client_secret=JqQX2PNo9bpM0uEihUPzyrh" -X POST https://login.microsoftonline.com/organizations/oauth2/v2.0/token
Step 4: Convert the mailbox username and bearer token (!!! 1787 characters long) into a base64 string
echo -n "user=test@contoso.onmicrosoft.com^Aauth=Bearer EwBAAl3BAAUFFpUAo7J3Ve0bjLBWZWCclRC3EoAA^A^A" | base64
The final base64 string is 2464 characters long and obviously WAY too long for SMTP to accept. Where am I going wrong with this?