I am trying to do the integration between Salesforce and Xero by using Named Credentials (Authentication Protocol is OAuth 2.0). I created an Auth provider -
Then created Named credentials of OAuth 2.0 type and authenticated with required scopes mentioned in the Xero developer document.
When I am trying to run the below code to get the Account details from Xero, I am getting "AuthenticationUnsuccessful".
HttpRequest req = new HttpRequest(); req.setEndpoint('callout:XeroDev/api.xro/2.0/Accounts'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); System.debug(res.getBody());
This is the response -
Any suggestion on how to make it work by using Named Credential?