コード例 #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);
        }
コード例 #2
0
        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();
 }