Example #1
0
        public async Task <UserToken> GetAccessTokenAsync(string authorizationCode)
        {
            var getAccessToken = RequestGenerator.GetAccessToken(_options.ClientId, _options.ClientSecret, _options.CallbackUrl, authorizationCode);
            var token          = await ExecuteAuthorization <UserToken>(getAccessToken);

            _options.AccessToken  = token.Access_Token;
            _options.RefreshToken = token.Refresh_Token;

            return(token);
        }
Example #2
0
        public async Task <UserToken> RefreshAccessTokenAsync()
        {
            var refreshAccessToken = RequestGenerator.RefreshAccessToken(_options.ClientId, _options.ClientSecret, _options.CallbackUrl, UserRefreshToken);
            var token = await ExecuteAuthorization <UserToken>(refreshAccessToken);

            _options.AccessToken  = token.Access_Token;
            _options.RefreshToken = token.Refresh_Token;

            return(token);
        }
Example #3
0
        public async Task <string> GetProfilePictureAsync(PictureSize size = PictureSize.Medium)
        {
            var response = await Execute(() => RequestGenerator.GetProfilePicture(size), _clientContentNoRedirection);

            var locationHeader = response.Headers.Location;

            if (locationHeader != null)
            {
                return(locationHeader.AbsoluteUri);
            }
            return(null);
        }
Example #4
0
        public async Task <FileInfo> UploadAsync(string parentFolderId, Stream content, string name, OverwriteOption overwrite = OverwriteOption.DoNotOverwrite, bool downsizePhotoUpload = false, bool checkForQuota = false)
        {
            if (checkForQuota)
            {
                var quota = await QuotaAsync();

                if (quota.Available <= content.Length)
                {
                    throw new NotEnoughQuotaException();
                }
            }

            return(await Execute <FileInfo>(() => RequestGenerator.Upload(parentFolderId, name, content, overwrite, downsizePhotoUpload)));
        }
Example #5
0
        public async Task <Stream> DownloadAsync(string id)
        {
            HttpResponseMessage restResponse = await Execute(() => RequestGenerator.Read(id), _clientContentNoRedirection);

            var locationHeader = restResponse.Headers.Location;

            if (locationHeader != null)
            {
                var stream = await _clientContent.GetStreamAsync(locationHeader.AbsoluteUri);

                return(stream);
            }

            return(null);
        }
Example #6
0
 public async Task <File> MoveFileAsync(string id, string newParentId)
 {
     return(await Execute <File>(() => RequestGenerator.Move(id, newParentId)).ConfigureAwait(false));
 }
Example #7
0
 public async Task DeleteAsync(string id)
 {
     await Execute(() => RequestGenerator.Delete(id)).ConfigureAwait(false);
 }
Example #8
0
        public string GetAuthorizationRequestUrl(IEnumerable <Scope> requestedScopes, string state = null)
        {
            var request = RequestGenerator.Authorize(_options.ClientId, _options.CallbackUrl, requestedScopes, state);

            return(request.BuildUri().AbsoluteUri);
        }
Example #9
0
 public async Task <UserQuota> QuotaAsync()
 {
     return(await Execute <UserQuota>(() => RequestGenerator.Quota()));
 }
Example #10
0
 public async Task DeleteAsync(string id)
 {
     await Execute(() => RequestGenerator.Delete(id));
 }
Example #11
0
 public async Task <Folder> MoveFolderAsync(string id, string newParentId)
 {
     return(await Execute <Folder>(() => RequestGenerator.Move(id, newParentId)));
 }
Example #12
0
        public async Task <IEnumerable <File> > SearchAsync(string pattern)
        {
            var result = await Execute <File>(() => RequestGenerator.Search(pattern)).ConfigureAwait(false);

            return(result.Data);
        }
Example #13
0
 public async Task <File> CopyAsync(string sourceId, string newParentId)
 {
     return(await Execute <File>(() => RequestGenerator.Copy(sourceId, newParentId)));
 }
Example #14
0
 public async Task <File> RenameFileAsync(string id, string name)
 {
     return(await Execute <File>(() => RequestGenerator.Rename(id, name)).ConfigureAwait(false));
 }
Example #15
0
 public async Task <Folder> CreateFolderAsync(string parentFolderId, string name, string description = null)
 {
     return(await Execute <Folder>(() => RequestGenerator.CreateFolder(parentFolderId, name, description)));
 }
Example #16
0
 public async Task <File> GetFileAsync(string id = null)
 {
     return(await Execute <File>(() => RequestGenerator.Get(id)));
 }
Example #17
0
        public async Task <IEnumerable <File> > GetContentsAsync(string id = null)
        {
            var result = await Execute <File>(() => RequestGenerator.GetContents(id));

            return(result.Data);
        }
Example #18
0
 public async Task <User> GetMeAsync()
 {
     return(await Execute <User>(() => RequestGenerator.GetMe()).ConfigureAwait(false));
 }
Example #19
0
 public async Task <User> GetMeAsync()
 {
     return(await Execute <User>(() => RequestGenerator.GetMe()));
 }
Example #20
0
 public async Task <Folder> RenameFolderAsync(string id, string name)
 {
     return(await Execute <Folder>(() => RequestGenerator.Rename(id, name)));
 }
Example #21
0
 public async Task <Folder> GetFolderAsync(string id = null)
 {
     return(await Execute <Folder>(() => RequestGenerator.Get(id)).ConfigureAwait(false));
 }
Example #22
0
 public async Task <UserQuota> QuotaAsync()
 {
     return(await Execute <UserQuota>(() => RequestGenerator.Quota()).ConfigureAwait(false));
 }