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
Vinod KumarVinod Kumar 

how to integrate to odesk from salesforce?

Hi all,

I am trying to integrate to odesk from salesforce. For that first i need authentication. I need frob key and token key. I am getting the frob key. At the time of getting token it is redirecting to odesk login page, and asking the authorize application after completion of authorisation i am getting the token.  According to my requirement it should not redirect to login page. Direct it should has to display the token. This is the message i am getting in the debug log 

 

<script type='text/javascript'>
window.location = 'https://www.odesk.com/login.php?redir=' + encodeURIComponent(window.location.href);
</script>

 

Can anybody please help me. How to do integration from salesforce to odesk?

 

Here i am pasting my code:

===================

 

public with sharing class CreationOfTask {
@future(callout=true)
public static void createTask() {
HttpRequest req = new HttpRequest();

String algName = 'MD5';
Blob frobsgn = Crypto.generateDigest(algName, Blob.valueOf('144b56512631fd19api_key88842145e1b3bf2c5ce644a2dbb99520'));
system.debug('frobsgn:'+frobsgn);
String frobUrl = EncodingUtil.urlEncode(EncodingUtil.convertToHex(frobsgn), 'UTF-8');
system.debug('frobUrl:'+frobUrl);

//req.setEndpoint('https://www.odesk.com/api/auth/v1/keys/frobs.xml?api_key=0dbf0aaedf1f9af72700e09205fcf4c8&api_sig=6d2df35cac46a305771716d397c6e7bb');
req.setEndpoint('https://www.odesk.com/api/auth/v1/keys/frobs.xml?api_key=88842145e1b3bf2c5ce644a2dbb99520&api_sig='+frobUrl);
req.setMethod('GET');
//req.setTimeout(60000);
Http http = new Http();
HTTPResponse res = http.send(req);
//Dom.Document doc = res.getBodyDocument();
//String xml = doc.toXmlString();
//system.debug('xmlbody--------:'+res.getBody());
system.debug('xmlstatus--------:'+res.getStatus());
dom.Document doc = res.getBodyDocument();
dom.Xmlnode node = doc.getRootElement().getChildElement('frob', null);
String frobval = node.getText();
system.debug('frob-------: '+frobval);

String token = '144b56512631fd19api_key88842145e1b3bf2c5ce644a2dbb99520'+frobval;
Blob tokenSign = Crypto.generateDigest(algName, Blob.valueOf(token));
String tokenUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(tokenSign), 'UTF-8');

HttpRequest req1 = new HttpRequest();
//req1.setEndpoint('https://www.odesk.com/api/auth/v1/keys/tokens.xml?frob=frobval&api_key=0dbf0aaedf1f9af72700e09205fcf4c8&api_sig=05c25a53f87f8ce133de0cd0695a1708');
//String endUrl = 'https://www.odesk.com/api/auth/v1/keys/tokens.xml?frob='+frobval+'&api_key=88842145e1b3bf2c5ce644a2dbb99520&api_sig='+tokenUrl;
String endUrl = 'https://www.odesk.com/services/api/auth/?api_key=88842145e1b3bf2c5ce644a2dbb99520&frob='+frobval+'&api_sig='+tokenUrl;
system.debug('endUrl:'+endUrl);
req1.setEndpoint(endUrl);
req1.setMethod('POST');
//req1.setMethod('GET');
Http http1 = new Http();
HTTPResponse res1 = http1.send(req1);
system.debug('xmlbody--------:'+res1.getBody());
}
}

===============

 

Thanks in advance.

 

Regards,

Vinod.