예제 #1
0
        private bool SetAuthenticationHeader(HttpRequestMessage httpRequestMessage, PixivOAuthResponse authResponse)
        {
            if (authResponse == null)
            {
                return(false);
            }

            httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResponse.AccessToken);
            return(true);
        }
예제 #2
0
        public async Task AddAuthResponseAsync(PixivOAuthResponse pixivOAuth)
        {
            var json     = JsonConvert.SerializeObject(pixivOAuth);
            var buffer   = Encoding.UTF8.GetBytes(json);
            var path     = GetPathWithBaseDirectory();
            var fileMode = File.Exists(path) ? FileMode.Truncate : FileMode.Create;

            using (var fileStream = new FileStream(path, fileMode))
            {
                await fileStream.WriteAsync(buffer);
            }
        }