fusion tables from google script -
I'm using this code in Google Script Fusion Tables in Google Script
Function getGAauthenticationToken (email, password) {password = encodeurIC component (password); Var response = UrlFetchApp.fetch ("https://www.google.com/accounts/ClientLogin", {Method: "Post", Payload: "AccountType = GOOGLE & amp; Email =" + Email + "& passwd =" + Password + "& service = fusiontables & source = test"}); Var responseStr = response.getContentText (); ResponseStr = responseStr.slice (responseStr.search ("at =") + 5, responseStr.length); ResponseStr = responseStr.replace (/ \ n / g, ""); Return response STR; } Function getdata (authToken) {query = encodeurIComponent ("Show tab"); Var URL = "http://www.google.com/fusiontables/api/query?sql=" + query; Var response = UrlFetchApp.fetch (URL, {method: "get", header: {"authorization": "GoogleLogin auth =" + authToken,}}); Return response. GetContentText (); } Function Test () {var email = "xyz@gmail.com"; Var pass = "xyz"; Var Token = getGAauthenticationToken (email, pass); Logger.log (GetData (token)); } But, how can I make a connection with OAuth 2.0 without user / pass?
No Oops 2.0, the application supports only Script 1.0. But you can use 1.0 generally with the Fusion Tables API. No need for user-related information Here's a function that I wrote a long time ago, so that my webfetting requests can be set to set up the ohph in Google API.
/ ** * Set up Google's oAuth authentication UrlFetch * @retuns {object} Usage URLFatch * @param {string} Name oh service Can be done for the name, anything can be done * but should not be between the different scope again; * Rare * * the ultimate {recommend the use of meaningful name related to the string} Scope scope for OUUT * * / Function googleOAuth (name, area) {var oAuthConfig = UrlFetchApp.addOAuthService (name); OAuthConfig.setRequestTokenUrl ("https://www.google.com/accounts/OAuthGetRequestToken?scope=" + scope); OAuthConfig.setAuthorizationUrl ("https://www.google.com/accounts/OAuthAuthorizeToken"); OAuthConfig.setAccessTokenUrl ("https://www.google.com/accounts/OAuthGetAccessToken"); OAuthConfig.setConsumerKey (anonymous); OAuthConfig.setConsumerSecret (anonymous); Return {oAuthServiceName: name, oAuthUseToken: "always"}; } Google Apps Script has still been added to the site, which will automate more things for you. Please have a look.
Comments
Post a Comment