+ 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 = 'https://login.salesforce.com/services/oauth2/userinfo?oauth_token='+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: https://help.salesforce.com/articleView?id=remoteaccess_using_userinfo_endpoint.htm&type=0

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 https://login.salesforce.com/services/data/v20.0/ -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