function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

'Missing_OAuth_Token' response while making rest callout using OAuth Endpoints

Hi All,

I wanted to get user info detail by using the salesforce OAuth  Apex Callout . I have the access token in my previous step.  Now I am setting the end point url with oauth_token parameter as below:
HttpRequest request = new HttpRequest();
 String endpoint = ''+accessToken;
 HttpResponse response = new Http().send(request);

I am getting the response  body as :Missing_OAuth_Token "System.HttpResponse[Status=Forbidden, StatusCode=403]".
referred documentation:

Please help.
​Thanks in Advance!!!
Hi Lata,

In the case of StatusCode = 403, The request has been refused. Verify that the logged-in user has appropriate permissions.


 Try the below code to get access once I got the JSON response parsed to get Access Token
String requestUrl = '/services/apexrest/v1/showAccount/';
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + accessToken);
HTTPResponse res = http.send(req);
String output = res.getBody();

Mukesh Kumar
Hi Mukesh,
Thanks for the reply. I have tried the  code provided ,it didn't work for me. And I am not sure about the user permission as the logged in user is a system admin.
rohit kumarrohit kumar
I beleive the oauth_token needs to put in the header as a param with the same name ..

curl -H 'Authorization: Bearer access_token'
You need to put access_token in the header of the request,

PS : for a reason it is always advised to test api first on POSTMAN... there are many benefits... one being that postman itself generates the post scripts in various  languages ..  javaScript/c#/php/ curl