示例#1
0
        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
        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();
        }