You need to sign in to do that
Don't have an account?
Carl H
Google Spreadsheets API authentication
Hi all,
I'm trying to make a connection to google Spreadsheet with the example provided in (http://wiki.apexdevnet.com/index.php/Google_Data_Authentication)
And i'm able to get the session token but then when i trying to get the spreadsheets list with the following code
But the system return me this error = "Illegal character(s) in message header value: AuthSub token="CJm1yZSmDhDemoas-f____8B "" and the "CJm1yZSmDhDemoas-f____8B" actually is my session token return from AuthSubUtil.exchangeForSessionToken(token)
Then i removed the "service.getSpreadsheets()" line (as above) and print the content of service and it return me below are the message
SpreadsheetService:[
canCallout=null,
debug=null,
response=null,
service=GoogleService:[AuthSubToken=CJm1yZSmDhDCwv-BAw ,canCallout=null,debug=0,gsessionid=null,response=null,responseXml=null,slug=null],
spreadsheets=null,
spreadsheetsfeed=null]
I don't really understand what is the problem why i'm unable to get the spreadsheet list from my Google Account. Does anyone can help me please???
Below is the javascript code to make the token request from google side. FYR
Message Edited by Carl H on 06-27-2008 05:53 AM
Message Edited by Carl H on 06-27-2008 06:12 AM
I'm trying to make a connection to google Spreadsheet with the example provided in (http://wiki.apexdevnet.com/index.php/Google_Data_Authentication)
And i'm able to get the session token but then when i trying to get the spreadsheets list with the following code
string token = ApexPages.currentPage().getParameters().get('token');
string sessToken = AuthSubUtil.exchangeForSessionToken(token);
SpreadsheetService service = new SpreadsheetService();
service.setAuthSubToken(sessToken);
GoogleData sheets = service.getSpreadsheets();
But the system return me this error = "Illegal character(s) in message header value: AuthSub token="CJm1yZSmDhDemoas-f____8B "" and the "CJm1yZSmDhDemoas-f____8B" actually is my session token return from AuthSubUtil.exchangeForSessionToken(token)
string token = ApexPages.currentPage().getParameters().get('token');
string sessToken = AuthSubUtil.exchangeForSessionToken(token);
SpreadsheetService service = new SpreadsheetService();
service.setAuthSubToken(sessToken);
Then i removed the "service.getSpreadsheets()" line (as above) and print the content of service and it return me below are the message
SpreadsheetService:[
canCallout=null,
debug=null,
response=null,
service=GoogleService:[AuthSubToken=CJm1yZSmDhDCwv-BAw ,canCallout=null,debug=0,gsessionid=null,response=null,responseXml=null,slug=null],
spreadsheets=null,
spreadsheetsfeed=null]
I don't really understand what is the problem why i'm unable to get the spreadsheet list from my Google Account. Does anyone can help me please???
Below is the javascript code to make the token request from google side. FYR
var scope = 'http://spreadsheets.google.com/feeds/spreadsheets/private/full/';
var forceReDirect = '/_ui/core/google/GoogleAuthSubCallback—url=' ;
var googleRedir = 'https://www.google.com/accounts/AuthSubRequest–next=';
var myApp = encodeURIComponent(window.location.pathname + "˜id={!$CurrentPage.parameters.id}" );
var nextUrl = window.location.protocol + '//' + window.location.host + forceReDirect + myApp ;
var tokenRequestUrl = googleRedir + encodeURIComponent( nextUrl ) + "&session=1&secure=0&scope="+ scope;
Message Edited by Carl H on 06-27-2008 05:53 AM
Message Edited by Carl H on 06-27-2008 06:12 AM
here is a new copy of the method that parses the token, should be an improvement ( authsubutil.cls )
Note, with AuthSub you can only get 10 valid tokens from google ( at one time), so generating a new one each time may be limiting, unless they are properly revoked ( by your app). If you do revoke them, then each visit to your app will require a new login to google. I'm concerned if someone gains a token, then navigates away from your app, will the token ever be revoked?
if you store the token somewhere and then make the call will that work?
Message Edited by Ron Hess on 06-27-2008 09:22 AM
Message Edited by Ron Hess on 06-27-2008 09:28 AM
the correct scope var for all spreadsheet authsub tokens is :
http://spreadsheets.google.com/feeds/
Thank you very much. It is working now after i have removed the empty space behind the token return from AuthSUbUtil.ExhangeForSessionToken and also put in the correct scope URL.
"If you do revoke them, then each visit to your app will require a new login to google. I'm concerned if someone gains a token, then navigates away from your app, will the token ever be revoked? if you store the token somewhere and then make the call will that work?" >> It won't be revoked, and it is still valid, but i dont know how long it valid for.
Message Edited by Carl H on 07-03-2008 08:27 AM