Google Apps Scripts OAuth use case with Tumblr. Run the startTumblrAuthorization
and follow the authorization workflow.
function getTumblrOAuthConfig_(){
// values available once an app is registered here: http://www.tumblr.com/oauth/apps
// registered app callback URL should be: https://script.google.com/macros
var consumer_key = "<OAuth Consumer Key>";
var consumer_secret = "<Secret Key>";
var oAuthConfig = UrlFetchApp.addOAuthService("Tumblr");
oAuthConfig.setAccessTokenUrl('http://www.tumblr.com/oauth/access_token');
oAuthConfig.setAuthorizationUrl('http://www.tumblr.com/oauth/authorize');
oAuthConfig.setRequestTokenUrl('http://www.tumblr.com/oauth/request_token');
oAuthConfig.setConsumerKey(consumer_key);
oAuthConfig.setConsumerSecret(consumer_secret);
return oAuthConfig;
}
function startTumblrAuthorization(){
var oAuthConfig = getTumblrOAuthConfig_();
var url = "http://api.tumblr.com/v2/user/info";
var options = {
"method": "GET",
"oAuthServiceName": "Tumblr",
"oAuthUseToken": "always"
};
var result = UrlFetchApp.fetch(url, options);
// If authorization is successful, on the next run, data are viewable in the "View > Logs…" menu
Logger.log(result.getContentText());
return oAuthConfig;
}