For several days now, I hit my head about this, trying to understand how this can be done. I want to download CSV from Google Webmaster Tools, which I can do. However, I must directly pass the username and password of the account I want to access. For all other aspects of webmaster tools, I just have a user login and I am changing the token from there using a reused session token.
I cannot use this method when it comes to receiving request data.
String next = "http://xyz.domain.com/auth"; //sets page to goto after user log 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 will receive a token after a successful login. Then you exchange it for a 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 its AuthSubToken to the session token and DONE!
WebmasterToolsService myService = new WebmasterToolsService("DemoWebmaster"); myService.setAuthSubToken(token);
However, when I try to download CSV, I have no choice but to use the full Google user credentials.
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 something with the webmasters API, as I pass full login. However, for the application that I am creating, I do not need to save Google credentials in full.
I saw one company that was somehow able to do this by adding the Google Webmaster APIs. But I canβt understand how this is possible. Any ideas?