Oauth2禁止创建用户

时间:2014-03-21 16:26:39

标签: c# oauth-2.0 google-api-dotnet-client

使用来自Google.apis.auth.OAuth2的OAuth2并收到“禁止”消息。除了启用API之外,在开发人员/应用程序控制台中找不到“允许”的位置。已启用Admin SDK,Google+ API。

以下是我收到的回复: 在Google Apps应用域中创建用户!

  

[lccFProcessGoogleAPI]错误:Google.Apis.Requests.RequestError   未授权访问此资源/ api [403]   错误[消息[未授权访问此资源/ api]位置[ - ]原因[禁止]域[全局]]

我正在使用VS 2013,C#。这是代码片段:

ServiceAccountCredential credential2 = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(lccSCSettings.lccSGoogleServiceAccountEmail)
    {
                               Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser }
                               //Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser, DirectoryService.Scope.AdminDirectoryUserSecurity, DirectoryService.Scope.AdminDirectoryGroup, DirectoryService.Scope.AdminDirectoryGroupMember, DirectoryService.Scope.AdminDirectoryOrgunit }
                               //Scopes = new[] { PlusService.Scope.PlusMe }
                           }.FromCertificate(certificate2));
                        User newuserbody = new User();
    [...]
                    var service2 = new DirectoryService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential2,
                ApplicationName = "lccGoogleAPI",
            });
           User results = service2.Users.Insert(newuserbody).Execute();

0 个答案:

没有答案