I have been bashing my head on this for days now trying to figure out how this is possible to do. I want to download the CSV's from Google Webmaster Tools which I have succeed in doing. However, I have to directly pass the username and password of the account I wish to access. For all other aspects of the webmaster tools, I simply have the user login and I exchange the token from there login with a re-useable session token.
I cant seem to use this method when it comes to getting the query data.
String next = "http://xyz.domain.com/auth"; //sets page to goto after user log's in so we can pass the token to application
String scope = "http://www.google.com/webmasters/tools/feeds"; // sets the scope of the token
boolean secure = false;
boolean session = true;
String urlFromAuthSub = AuthSubUtil.getRequestUrl(next, scope, secure, session); //generates the URL to forward user to loginto google.
On your capture page (the next parameter in the code above) you receive the token after successful login. Then you exchange it for the session token.
String token = "##########################";
String sessionToken = AuthSubUtil.exchangeForSessionToken(token, null);
//store sessionToken for all future use to interact with webmaster for this user.
Then finally we simply create our WebmasterToolsService
object and set it's AuthSubToken
to the session token, and DONE!
WebmasterToolsService myService = new WebmasterToolsService("DemoWebmaster");
myService.setAuthSubToken(token);
However when trying to download the CSV, I have no choice but to use full credentials of the Google user.
String host = "www.google.com";
String dl_list_url = "/webmasters/tools/downloads-list?hl=%s&siteUrl=%s";
String sites_path = "/webmasters/tools/feeds/sites/";
WebmasterToolsService svc = new WebmasterToolsService("DemoQuery Service");
svc.setUserCredentials("xyz@domain.com", "123456");
After that I can do anything with the webmaster API as I am passing the full client login. However, for the application I am building, I need to not store the users full Google credentials.
I seen one company that has managed to pull this off somehow when you add the Google webmaster API. But I cant seem to see how it is possible. Any ideas?