+ Start a Discussion
nagalakshminagalakshmi 

How to pass the access token for getting data from external application

Hi,

 

I am doing gotowebinar integration with salesforce. I am getting access token,refresh token,client id, organization key of gotowebinar in to salesfoce visualforce page. I have stored the accesstoken of gotowebinar in to one variable through apex class. When i am trying to get the data from gotowebinar to salesforce, it will throughs the error as

 

{"int_err_code":"InvalidToken","msg":"Invalid token passed"}

 

I have use the code for getting attendees details through this method.

 

public void performance()
{
s1=apexpages.currentpage().getparameters().get('code');
system.debug(accesstoken+'aaa==');
Http h = new Http();
HttpRequest req = new HttpRequest();
final string username = 'username';
final string password = 'welcome1';
//Blob headerValue = Blob.valueOf(username + ':' + password);
//String authorizationHeader = 'BASIC' + EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader+accesstoken);
//String authorizationHeader = 'OAuth' +accesstoken +EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader);
//req.setHeader('Authorization', 'OAuth ' +accesstoken);
//req.setHeader('Host','https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
//req.setHeader('Authorization', 'OAuth '+accesstoken);
req.setHeader('Authorization:', 'OAuth oauth_token='+accesstoken);
//req.setHeader('Authorization: OAuth oauth_token=', accessToken);

req.setHeader('Connection','keep-alive');
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
req.setMethod('GET');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/accesstoken/attendees/{registrantKey}');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/performance');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/'+accesstoken+'/performance');
req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
system.debug(accesstoken+'aaa1==');
system.debug(req+'hh==');
HttpResponse res = h.send(req);
system.debug(accesstoken+'aaa2==');
res2=res.getbody();
system.debug('********'+res.getbody());
system.debug('111=='+res.getstatus());

}

 

Please help me, how to solve this issue.. Thanks in advance..

 

Thanks,

Lakshmi

WaveOCWaveOC
As i understand you need to refresh auth token using refresh token provided on autherization. I think auth token has 1 hour maxAge before it becomes invalid. I am not sure how this works in Citrix API but usually you need to change grant_type to refresh_token and also pass refresh_token as a parameter - https://some.url/getToken?grant_type=refresh_token&refresh_token=7ae3a10234234161914ec65b8db6650c