示例#1
0
        private async void TryRefreshToken(Action <LiveLoginResult> completionCallback)
        {
            LiveLoginResult result = await this.AuthClient.AuthenticateAsync(
                LiveAuthClient.BuildScopeString(this.currentScopes),
                true);

            if (result.Status == LiveConnectSessionStatus.NotConnected &&
                this.currentScopes.Count > 1)
            {
                // The user might have revoked one of the scopes while the app is running. Try getting a token for the remaining scopes
                // by passing in only the "wl.signin" scope. The server should return a token that contains all remaining scopes.
                this.currentScopes = new List <string>(new string[] { LiveAuthClient.SignInOfferName });
                result             = await this.AuthClient.AuthenticateAsync(
                    LiveAuthClient.BuildScopeString(this.currentScopes),
                    true);
            }

            if (result.Status == LiveConnectSessionStatus.Unknown)
            {
                // If the auth result indicates that the current account is not connected, we should clear the session
                this.Session = null;
            }
            else if (result.Session != null && !LiveAuthClient.AreSessionsSame(this.Session, result.Session))
            {
                this.Session = result.Session;
            }

            completionCallback(result);
        }
示例#2
0
        private async Task <LiveLoginResult> ExecuteAuthTaskAsync(IEnumerable <string> scopes, bool silent)
        {
            if (scopes != null)
            {
                this.scopes = new List <string>(scopes);
            }

            this.EnsureSignInScope();
            this.PrepareForAsync();

            LiveLoginResult result = await this.AuthClient.AuthenticateAsync(
                LiveAuthClient.BuildScopeString(this.scopes),
                silent);

            if (result.Session != null && !LiveAuthClient.AreSessionsSame(this.Session, result.Session))
            {
                this.MergeScopes();
                this.Session = result.Session;
            }

            Interlocked.Decrement(ref this.asyncInProgress);

            if (result.Error != null)
            {
                throw result.Error;
            }

            return(result);
        }