I tried to use the google apps reseller api with google apps script. To use oauth I need the AuthServiceName. what is the right name? "apps" does not work.
Asked
Active
Viewed 780 times
1 Answers
1
AuthServiceName is defined in your application, its not dependent on the API that you are connecting to, i would suspect that you may not have completed all the steps necessary or that your oauth call is not properly structured.
Here is an example of a call that retrieves the details of domains.
function getCustomer() {
//set up oauth for Google Reseller API
var oAuthConfig1 = UrlFetchApp.addOAuthService("doesNotMatter");
oAuthConfig1.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/apps.order.readonly");
oAuthConfig1.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig1.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=https://script.google.com/a/macros");
oAuthConfig1.setConsumerKey(CONSUMER_KEY);
oAuthConfig1.setConsumerSecret(CONSUMER_SECRET);
var options1 = {oAuthServiceName:"doesNotMatter", oAuthUseToken:"always",
method:"GET", headers:{"GData-Version":"3.0"}, contentType:"application/x-www-form-urlencoded"};
//set up user profiles url
var theUrl = "https://www.googleapis.com/apps/reseller/v1/customers/somedomain.com";
//urlFetch for customer list
var customerInfo = "";
try {
var response = UrlFetchApp.fetch(theUrl,options1);
customerInfo = response.getContentText();
} catch(problem) {
Logger.log(problem.message);
}
Logger.log(customerInfo);
}
This will work if
- You have a reseller account (I guess i.e. I did not test on my non reseller account)
- You have create a project in the API console, and enabled the Reseller API
- You know your SECRET and KEY lifted form the console
- I have use a read.only scope which is safe, if not you need to set up your tests in the sand box
Let me know if you need any more clarifications

patt0
- 810
- 4
- 8
-
Thank you very much. I tried with "anonymous" as secret and key and got "usageLimits" errors. So it seems better to use a specific secret and key. How to get one in the concole? Should I take the domain key and secret? How to get the key? – user1488842 Sep 14 '13 at 14:52
-
everything you ever need to know about the API console is here : https://developers.google.com/console/help/ – patt0 Sep 15 '13 at 03:00
-
Thank you very much ... I used my secret and key with your script code and got this error: wrong value oAuthServiceName ... – user1488842 Sep 15 '13 at 16:32