首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >whar是google应用程序经销商api的oauth服务名称。

whar是google应用程序经销商api的oauth服务名称。
EN

Stack Overflow用户
提问于 2013-09-13 21:11:13
回答 1查看 771关注 0票数 0

我试着用google应用程序脚本来使用google应用程序分销商api。要使用oauth,我需要AuthServiceName。正确的名字是什么?“应用程序”不起作用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-14 04:24:45

AuthServiceName是在您的应用程序中定义的,它不依赖于您所连接的API,我怀疑您可能还没有完成所有必要的步骤,或者您的oauth调用结构不正确。

下面是一个检索域详细信息的调用示例。

代码语言:javascript
复制
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);

}

如果

  1. 你有一个分销商帐户(我想我没有在我的非经销商帐户上进行测试)
  2. 您已经在API控制台中创建了一个项目,并启用了Reseller。
  3. 你知道你的秘密和钥匙是从控制台上拿出来的
  4. 我使用了一个安全的read.only范围,如果不是,您需要在沙箱中设置测试。

如果你需要更多的澄清,请告诉我。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18795332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档