コード例 #1
0
ファイル: BandCloudClient.cs プロジェクト: talmuth/unBand
        private async void OnLiveAuthCompleted(AuthResult result)
        {
            _tokens = new LiveAuthTokens()
            {
                AccessToken  = result.AccessToken,
                RefreshToken = result.RefreshToken,
                Expires      = result.Expires
            };

            var req = HttpWebRequest.Create(LOGIN_HOST_URL + LOGIN_URL);

            req.Headers.Add("Authorization", _tokens.AccessToken);
            var response = await req.GetResponseAsync();

            var stream = response.GetResponseStream();

            using (var reader = new StreamReader(stream))
            {
                var responseText = await reader.ReadToEndAsync();

                System.Diagnostics.Debug.WriteLine(responseText);

                _cloudAuthentication = JsonConvert.DeserializeObject <BandCloudAuthentication>(responseText);

                _cloudAuthentication.AuthorizationHeader = response.Headers["Authorization"];
            }

            if (AuthenticationCompleted != null)
            {
                AuthenticationCompleted();
            }
        }
コード例 #2
0
ファイル: BandCloudClient.cs プロジェクト: misspierc/unBand
        private async void OnLiveAuthCompleted(AuthResult result)
        {
            _tokens = new LiveAuthTokens()
            {
                AccessToken = result.AccessToken,
                RefreshToken = result.RefreshToken,
                Expires = result.Expires
            };

            var req = HttpWebRequest.Create(LOGIN_HOST_URL + LOGIN_URL);
            req.Headers.Add("Authorization", _tokens.AccessToken);
            var response = await req.GetResponseAsync();
            var stream = response.GetResponseStream();

            using (var reader = new StreamReader(stream))
            {
                var responseText = await reader.ReadToEndAsync();
                System.Diagnostics.Debug.WriteLine(responseText);

                _cloudAuthentication = JsonConvert.DeserializeObject<BandCloudAuthentication>(responseText);

                _cloudAuthentication.AuthorizationHeader = response.Headers["Authorization"];
            }

            if (AuthenticationCompleted != null)
                AuthenticationCompleted();
        }