Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
vamsikrishna_chintharlapa
Product and Topic Expert
Product and Topic Expert

Most common issues facing while setting up OAuth 2.0 configuration in SAP PI\PO,  You can find more details below.

 1)if the value of refresh token as displayed on browser is 0.ALSKDHLAKSYOQEW…..alsdll, then in channel add following value “0.ALSKDHLAKSYOQEW…..alsdll”).

 

Solution: In case of multi server environment, the OAuth tokens stored in the Cache are not retrieved properly. This leads to failure of the scenario during the runtime (error being: Refresh token has to be generated again)

 

Please apply the patch as present in this note (  3169585 ). After applied while generating the refresh token the value of the token is displayed on the screen( You can copy the token value) ,  Additionally a new “Additional Parameter” (as shown in the below screenshot) is added for the mail sender channel with the name as ‘IMail.refreshToken’ and the value of refresh token should be stored with this parameter in the mail sender channel (Make sure you include double quotes in your token)


 

2)Key ID **************************************_Refresh already exists in database: com.sap.sql.exception.OpenSQLIntegrityConstraintViolationException: ORA-00001: unique constraint (UNKNOWN.obj#=*********) violated

       OpenSQLExceptionCategories: [NON_TRANSIENT, INTEGRITY_CONSTRAINT_VIOLATION]

 

Solution: From SP24 onwards once refresh token generated successfully no need to generate it again, If you generate you will get exception like above, Existing token will be available as per the time line in DB.


 

3)Can I enable startTLS enable for OAuth Scenarios

Solution: For OAuth Scenario you should be disable StartTLS parameter, If you set both OAuth\StartTLS together  you will get the exception  saying connection error.


 

4) “Peer Certificate error” while generating the refresh token

Solution: If you facing an error like  “Peer Certificate error” while generating the refresh token then, please follow the below steps :




    • Download the below certificates from Microsoft site

        • BaltimoreCyberTrustRoot.crt

        • DigiCertGlobalCAG2 (1).crt

        • DigiCertGlobalRootCA.crt

        • stamp2.login.microsoftonline.com.crt


 

    • Please import all the certificates under TrustedCAs view(in NWA page) one by one with X509 category, You can see in browser site view information.

 

    • Try generating the refresh token again. It will be successful



 

5)Not able to find  Trace Location in XPI trace example:com.sap.aii.af.sdk.xi.util.MailOAuthUtil

Solution: 1761446 - Creating custom trace locations for 7.10/7.11/7.30 system


 

 

6)Can I use Redirect URIs  scheme will be http?

Solution: Redirect URIs  scheme will be https, I think http will be only for localhost.


 

 

7)Error: RefreshToken has to be generated again.

Solution: Solution: Please apply the patch as present in this note (  3169585 ). After applied while generating the refresh token the value of the token is displayed on the screen( You can copy the token value) ,  Additionally a new “Additional Parameter” (as shown in the below screenshot) is added for the mail sender channel with the name as ‘IMail.refreshToken’ and the value of refresh token should be stored with this parameter in the mail sender channel.


 

8)PI\PO OAuth Logs with XPI Inspector

Solution:

 

Refresh Token Generation Issue:

 

com.sap.aii.af.sdk.xi.util.MailOAuthUtil

 

com.sap.aii.adapter.soap.web.MessageServlet

 

For all Mail Adapter OAuth issues:

 

com.sap.aii.adapter.mail

 

com.sap.aii.af.sdk.xi.net

 

com.sap.aii.af.sdk.xi.srt


 

 

9)Exception able to connect to the mailbox via Oauth, but after a few hours we started to get this error:

Solution: If you are in multi server node environment , From SP24 onwards once refresh token generated successfully no need to generate it again, If you generate you will get exception, Existing token will be available as per the time line.


 

 

10)Exception caught during processing mail message; java.io.IOException: Reason : :"AADSTS9002313: Invalid request. Request is malformed or invalid.\r\nTrace ID: .....\r\nCorrelation ID: XXXX\r\nTimestamp: ......."

Solution: If you are providing refresh token as additional parameter in the channel , please make sure include double quotes in your token.


 

11)Authentication Unsuccessful\Connection timeout \ Failed to call the endpoint  [null "null"]; nested exception caused by

 

Solution: Please check with network team to get the logs for user, Issue seems to be 587 port block or some firewall is blocking in organisation.


 

12)Changing client ID in channel

 

Exception caught during processing mail message; java.io.IOException: Reason : :"AADSTS700016: Application with identifier '73dd' was not found in the directory 'company'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.\r\nTrace ID: cfd00\r\nCorrelation ID: ea4134c85\r\nTimestamp: 2022-12-08 16:18:40Z"

 

Solution: Client ID is the one of the prerequisite parameter to generate refresh token , if you change it will redirect to different address. You have to generate token again with new ID.


 

13)A3 BAD USER IS AUTHENTICATED BUT NOT CONNECTED.

Solution:

 

1) Remove browser cache and try again. or "new incognito window"

 

2)  configuration tasks in the Azure Active Directory, user should have roles. Please check required roles for user with Azure team.


 

14) Refresh token generation in different SPs:




    1.  (SP16 to SP23 single server node)You can generate refresh token and token will be saved in    cache for 90 days, In between system\instance restart you have to generate it again.

 

    1.  (SP16 to SP23 Multiserver node) In case of multi server environment, the OAuth tokens     stored in the Cache are not retrieved properly. This leads to failure of the scenario during the runtime,  Please apply the patch as present in this note  3169585. Additionally a new "Additional Parameter" is added for the mail sender channel with the name as 'IMail.refreshToken' and the value of refresh token should be stored with this parameter in the mail sender channel.

 

    1. From SP24 (Note:  3165141) onwards Refresh token will generate and save in DB table, no need to regenerate when system\instance restart.



Note: Refresh token gets expired in 90 days(by default).


15) New Message Servlet for OAuth from SP28  onwards.

3321222 - New Servlet for token generation in PI Mail adapter

From SP28 onwards ,the URL is now changed to the following by doing code changes . The older SPs do not need to implement these changes . The new URL is :

“http://<host>:<port>/ XIMAILAdapter/MailOAuthServlet?channel=<Channel-Name>&party=<Party-Name>&service=<Service-Name>”

 16)When OAuth is used in the mail adapter for authentication several issues are observed such as:
      A3 BAD User is authenticated but not connected.
      Authenticate Failed.
     Slow processing of mails with large attachment.
     Inline attachments are not processed properly.
      Mail with singed content/attachment is not processed.

Solution

The issue is fixed through code changes from SP24 onwards. The option to use javax mail api or microsoft graph api is available at the channel level and the advanced parameter "IMail.useGraphAPI" should be set to true to indicate to the channel to use Microsoft Graph API for connecting and processing the mails using Graph API. By default the value of the parameter is false and hence javax mail api will be used. The refresh token has to generated again after setting the parameter to true and by changing the scope in the refresh token url to "https://graph.microsoft.com/.default".

Please note that with this change, the mailbox folder name is case sensitive. While setting the connection URL in the channel configuration kindly set the folder name precisely as to the one present in the O365 mailbox.

Note:3404237 - Addition of Microsoft Graph as an underlying API in mail adapter with OAuth. (sap.corp)