2012-12-06 45 views
1

借助Google Drive API,我可以使用OAuth2.0初始化DriveService对象,但不知道如何初始化Google Provisioning API的AppsService对象以与域Gorups和用户一起使用。我试过如何使用Google Provisioning API与Google云端硬盘API一起使用域组和用户?

AppsService _appService = new AppsService(“DOMAINNAME”,“AuthenticationTokenFromDriveServiceObj”);

但是,获得“荣军令牌”例外。

  1. 看起来Google Provisioning API仍然无法处理Google Drive API。我在这里纠正?
  2. Google Provisioning API是否被Google弃用?参考链接https://developers.google.com/google-apps/admin-api-deprecation-list

编辑:

我从给定的代码获得驱动服务对象: https://developers.google.com/drive/delegation#instantiate_a_drive_service_object [这里,我尝试添加配置API范围也] 然后

PermissionList permissions = _DriveSevice.Permissions.List("root").Fetch(); 
string userName = permissions.Items[0].Name; 
string authenticationToken = auth.State.AccessToken; 
AppsService _AppService = new AppsService("DOMAINNAME", authenticationToken); 
_AppsService.RetrieveAllUsers(); //This statement errors out 

回答

-2

Drive API和Provisioning API的作用域有所不同,无法共享OAuth凭据。您需要单独通过Provisioning API的OAuth流程,它们完全不相关的API。

Provisioning API尚未弃用。该清单适用于受弃用政策约束的API,发布时间为https://developers.google.com/google-apps/admin-api-terms

+1

你是正确的,他们是不同范围,但有没有必要通过2个身份验证工作流程,以推动用户。提出请求时,您只需在两个范围之间放置一个空格。 –

+0

@JayLee是对的 – Jerome

0

您只需使用setOauth2Credentials和Oauth2凭证,用于在应用服务实例上实例化Drive实例,当然,前提是您的令牌对Drive和Provisioning API的范围有效。

Here是的oauth2作用域的配置API

+0

我尝试过使用Drive和Provisioning API的所有作用域,但仍然收到未经授权的错误。 – Jeevan

+0

你能用你用来获取令牌的代码更新你的问题吗? – Jerome

+0

我已更新代码以获取令牌 – Jeevan

相关问题