Пример #1
0
        public async Task <AccountConfiguration> CreateAccount()
        {
            var isOk = OAuth2Flow.TryAuthenticate(this);

            if (!isOk)
            {
                return(null);
            }

            var api = await GoogleDriveHelper.GetClient(_token);

            var query = api.About.Get();

            query.Fields = "user";
            var about = await query.ExecuteAsync();

            var account = new AccountConfiguration()
            {
                Type   = StorageType.GoogleDrive,
                Id     = about.User.PermissionId,
                Name   = about.User.DisplayName,
                Secret = _token.RefreshToken
            };


            return(account);
        }
        protected async Task <DriveService> GetApi()
        {
            if (_api == null)
            {
                _api = await GoogleDriveHelper.GetClient(_account);
            }

            return(_api);
        }
Пример #3
0
        public async Task <AccountConfiguration> CreateAccount()
        {
            var account = new AccountConfiguration()
            {
                Type = StorageType.GoogleDrive
            };

            var api = await GoogleDriveHelper.GetClient(account);

            var query = api.About.Get();

            query.Fields = "user";
            var about = await query.ExecuteAsync();

            account.Id   = about.User.PermissionId;
            account.Name = about.User.DisplayName;

            return(account);
        }
Пример #4
0
 public async Task<AccountConfiguration> CreateAccount()
 {
     var flow = GoogleDriveHelper.CreateOidcFlow();
     return await flow.AuthorizeAsync();
 }