+ Start a Discussion
Kathryn BullockKathryn Bullock 

Do I need the O Auth?

Hi All,

I am trying to bring shipping information from XPO Logistics into Salesforce.  I was given a bearer token and I have to go through Postman to refresh the token every 12 hours.  Will I need to do an OAuth?  If so, will the callback URL be the Postman, the XPO Logistics or Salesforce?  I am very confused about what the callback URL does, and how I would get the callback URL if I need to get one on Postman.  Please help!
v varaprasadv varaprasad
Hi Kathryn,

Please check once below smple code.

If you want to connect other system then they will provide us 
 1. Client id 
2. Client secret
3. Oauth toke url
Using above id nd secret we can generate the access token.
String tokenBody = 'grant_type=client_credentials&client_id=ssssssssssssss6&client_secret=Ssssssssssssss';
        Http http = new Http();
        HttpRequest tokenReq = new HttpRequest();
        tokenReq.setEndpoint('https:/Oauth token URL/oauth/token');        
        system.debug('### value of tokenReq:::::::'+tokenReq);
        HTTPResponse resp = http.send(tokenReq);
        if(resp.getStatusCode() == 200 || resp.getStatusCode() == 201){
            system.debug('Token Response >>>>'+resp.getBody());
           //in the body we will get accesstoken

Once you get access token using that we can get the details from XPO.
4. Here XPO  again other URL will provide you to get the details
Endpoint url = 'xpo   ppppppppp  '
;req = new HttpRequest();
            req.setHeader('Authorization', 'Bearer '+aToken);
            req.setHeader('Content-Type', 'application/json');
            Http htp = new Http();
            res = new HttpResponse();
                res = htp.send(req);
                //Helpful debug messages
                System.debug('STATUS:' + res.getStatus());
                System.debug('STATUS_CODE:' + res.getStatusCode());
                String responseXML = res.getBody();
                System.debug('Response:' + responseXML);
            }catch(System.CalloutException e){
                system.debug('callout error mesage'+e.getMessage());
                system.debug('callout error mesage'+e.getTypeName());
                system.debug('callout error mesage'+e.getLineNumber());
                system.debug('callout error mesage'+e.getCause());

Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

@For Support: varaprasad4sfdc@gmail.com

Kathryn BullockKathryn Bullock
Thank you for the fast answer!  Unfortunately, I was not given the client ID or the secret, only the bearer token.  Also, does that make the callback ID Postman?  Really thank you for your help!!!