Failure to integrate Microsoft Office 365 Email Account with Microsoft Graph

Hi,

I am configuring an Email Account with Microsoft Office 365 as the email provider.

Using Microsoft Graph as the Receiver, but currently getting the following issue and the connectivity fails.

Failed while retrying to fetch accesstoken for clientID = [ClientID]: Access token endpoint invocation failed : {ErrorMessage=Response status : 400 Bad Request, statuscode=400}

The Auth profile is OAuth 2.0 type.

Is there a fix for this issue?

TIA

@MaleeshaW

Based on the error description, It looks like we are unable to fetch the token as Microsoft Graph complains that the token request is not valid. This could be possible if OAuth2.0 configuration is not correct or not inline with what Microsoft Graph expects. Please refer to this Pega article for detailed explanation on how to configure OAuth2.0 authentication for sending and receiving emails using Microsoft Graph. Please let me know if the problem still persists.

Thanks.

@MaleeshaW
Can you try to first get the token via Postman.
Can you also share the url the you have configured in the authentication profile.

Thanks,
Himanshu Negi

@MaleeshaW Using get method or post method? Can you try post method in the Auth profile.

@MaleeshaW Hi,

I am facing issue. Did you get a resolution for this?

@JillHaria The issue was with the application needing an access token to call Microsoft Graph. We followed the steps specified in https://docs-previous.pega.com/data-management-and-integration/86/configuring-oauth-20-authentication-sending-and-receiving-emails-using-microsoft-graph?check_logged_in=1.

Also, requested the client to create an app with the following permissions:

  • Mail.Send
  • User.Read
  • Mail.ReadWrite

and used client credentials as the grant type in Auth profile.

Hi all,
For anyone arriving on this thread from intense googling of 400 error on Pega / Azure, the Doc does forgot a very important point : the scope.

In your Auth Profile you must set the scope to “.default” otherwise Microsoft Graph will keep returning 400 and the debugging tool from Pega is not helpful since it does not display the body of the error sent by Microsoft and if you switch to Microsoft API v1.0 the error becomes a 401 which is even more confusing.

Another weird behavior was that switching to SMTP for outbound email account while having the Oauth Auth profile set up with v1.0 and empty scope was working while the Microsoft Graph kept send the 401.

Would be nice to add the scope details into the doc and integrate the body of the HTTP error into the testing tool, I had to curl my way out of there. On the other hand the debugging logs for SMTP rock !

Hope this answer saved someone’s time.

Kind regards !