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
vinsrivvinsriv 

Help in the last step of Salesforce Linkedin Integration

Hi,

 

I am in the last step of Salesforce Integration with Linked in. I got oauth_token and oauth_token_secret in my response .

 

Now i have to use it and make the API call to get the data.

 

I am trying it with the following code

 

        final String TripItAccessDataUri='https://api.linkedin.com/v1/people/~/format/json';

         Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        req.setEndpoint(TripItAccessDataUri);

 

     final String oAUth_BASE_signature =   

 SignatureBaseStringForAccessData(TripItAccessDataUri,unAuthorisedToken,unAuthorisedKey,nonceValue,timeStamp ,oauth_token_secret);

 

 

String signature = SignatureForAccessData(oAUth_BASE_signature ,consumerKey_Secret+'&'+unAuthorisedKey);

 

req.setHeader('Authorization','OAuth realm=\"https://api.linkedin.com/\",oauth_nonce=\"'+nonceValue+'\",oauth_signature_method=\"'+oauth_signature_method+'\",oauth_timestamp=\"'+timeStamp+'\",oauth_consumer_key=\"'+oauth_consumer_key+'\",oauth_token=\"'+oauth_token_secret+'\",oauth_signature=\"'+signature+'\",oauth_version=\"'+oauth_version+'\"');

 

reqstr ='Signature' + signature +'###OAuth realm=\"https://api.linkedin.com/\",oauth_nonce=\"'+nonceValue+'\",oauth_signature_method=\"'+oauth_signature_method+'\",oauth_timestamp=\"'+timeStamp+'\",oauth_consumer_key=\"'+oauth_consumer_key+'\",oauth_token=\"'+oauth_token_secret+'\",oauth_signature=\"'+signature+'\",oauth_version=\"'+oauth_version+'\"';

 

HttpResponse res = h.send(req);

resData =  res.getBody();

 

 

 

 

 

 

public String SignatureBaseStringForAccessData(String TripItAccessDataUri,String unAuthorisedToken,String unAuthorisedKey,String  nonceValue ,Long timeStamp, String oauth_token_secret) {
        String httpmethod = 'GET';

       String oAUTH_PARA='oauth_consumer_key='+oauth_consumer_key+'&oauth_nonce='+nonceValue +'&oauth_signature_method='+oauth_signature_method+'&oauth_timestamp='+timeStamp+'&oauth_token='+oauth_token_secret+'&oauth_version='+oauth_version+'';
        String BASE_STRING = httpmethod+'&'+EncodingUtil.urlEncode(TripItAccessDataUri,'UTF-8')+'&'+EncodingUtil.urlEncode(oAUTH_PARA,'UTF-8');
        return BASE_STRING;
    }

 

 

public String SignatureForAccessData(String Signature_Base_Value,String Key){
          Blob mac = Crypto.generateMac('HmacSHA1',Blob.valueOf(Signature_Base_Value),Blob.valueOf(Key));
          String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac),'UTF-8');
          return macUrl;

    }

 

 

       

 


Please have a look at it for 5 mins . any suggestion would be helpful . This is really urgent

 

 

Thanks in advance!!

 

 

 

 

Vineet

Best Answer chosen by Admin (Salesforce Developers) 
vinsrivvinsriv

I got the data . The issue was with the special character '~' .

 

I tried using 'https://api.linkedin.com/v1/people/%7E . I returned me the data .

 

Now my requirement is to get the shared connections between two profiles.

 

Regards,

Vineet

All Answers

vinsrivvinsriv

I am getting this in my response. Any clue where i am goin wrong.

 

<error>
  <status>401</status>
  <timestamp>1360148215543</timestamp>
  <request-id>UXQHGT0XOJ</request-id>
  <error-code>0</error-code>
  <message>[unauthorized]. The token used in the OAuth request is not valid. xxxxxxxxxxxxxxxxxxxxxx</message>
</error>

vinsrivvinsriv

After trying with different combinations, now i am getting this error

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <error> <status>401</status> <timestamp>1360221298372</timestamp> <request-id>JL9ONY5YKG</request-id> <error-code>0</error-code> <message>[unauthorized]. OAU:glho500p9lap|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|*01|*01:1360221297:Ew4DNQHPIKf1wlb/iD3g9kkpm+I=</message> </error>

 

 

Anyone has solution for this

vinsrivvinsriv

I got the data . The issue was with the special character '~' .

 

I tried using 'https://api.linkedin.com/v1/people/%7E . I returned me the data .

 

Now my requirement is to get the shared connections between two profiles.

 

Regards,

Vineet

This was selected as the best answer