Exemplo n.º 1
0
        /// <summary>
        /// Attempt to sign in developer account, UI will be triggered if necessary
        /// </summary>
        /// <param name="accountSource">The account source where the developer account was registered.</param>
        /// <param name="userName">The user name of the account, optional.</param>
        /// <returns>DevAccount object contains developer account info.</returns>
        public static async Task <DevAccount> SignIn(DevAccountSource accountSource, string userName)
        {
            lock (initLock)
            {
                if (Client == null)
                {
                    switch (accountSource)
                    {
                    case DevAccountSource.UniversalDeveloperCenter:
                        Client = new AuthClient(new AadAuthContext());
                        break;

                    case DevAccountSource.XboxDeveloperPortal:
                        Client = new AuthClient(new MsalAuthContext());
                        break;

                    default:
                        throw new XboxLiveException("Unsupported developer type");
                    }
                }
                else if (Client.HasCredential)
                {
                    throw new XboxLiveException("Dev account already signed in");
                }
            }

            return(await Client.SignInAsync(userName));
        }
Exemplo n.º 2
0
 private async void SingInout_Click(object sender, EventArgs e)
 {
     try
     {
         this.btnSingInout.Enabled = false;
         if (this.signedInuser != null)
         {
             ToolAuthentication.SignOut();
             this.signedInuser = null;
         }
         else
         {
             DevAccountSource accountSource = DevAccountSource.WindowsDevCenter;
             this.signedInuser = await ToolAuthentication.SignInAsync(accountSource, null);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error");
     }
     finally
     {
         this.UpdateAccountPanel();
         this.btnSingInout.Enabled = true;
     }
 }
 internal static void SetAuthInfo(DevAccountSource accountSource, string userName)
 {
     lock (initLock)
     {
         Client.AuthContext = CreateAuthContext(accountSource, userName);
     }
 }
        internal DevAccount(XdtsTokenResponse etoken, DevAccountSource accountSource)
        {
            object value;

            if (etoken.DisplayClaims.TryGetValue("eid", out value))
            {
                this.Id = value.ToString();
            }

            if (etoken.DisplayClaims.TryGetValue("enm", out value))
            {
                this.Name = value.ToString();
            }

            if (etoken.DisplayClaims.TryGetValue("eai", out value))
            {
                this.AccountId = value.ToString();
            }

            if (etoken.DisplayClaims.TryGetValue("eam", out value))
            {
                this.AccountMoniker = value.ToString();
            }

            if (etoken.DisplayClaims.TryGetValue("eat", out value))
            {
                this.AccountType = value.ToString();
            }

            this.AccountSource = accountSource;
        }
        /// <summary>
        /// Attempt to sign in developer account, UI will be triggered if necessary
        /// </summary>
        /// <param name="accountSource">The account source where the developer account was registered.</param>
        /// <param name="userName">The user name of the account, optional.</param>
        /// <returns>DevAccount object contains developer account info.</returns>
        public static async Task <DevAccount> SignInAsync(DevAccountSource accountSource, string userName)
        {
            SetAuthInfo(accountSource, userName);

            DevAccount devAccount = await Client.SignInAsync();

            SaveLastSignedInUser(devAccount);

            return(devAccount);
        }
        // Test hook
        internal static async Task <DevAccount> SignInAsync(DevAccountSource accountSource, string userName, IAuthContext authContext)
        {
            Client.AuthContext = authContext;

            DevAccount devAccount = await Client.SignInAsync();

            SaveLastSignedInUser(devAccount);

            return(devAccount);
        }
        private static IAuthContext CreateAuthContext(DevAccountSource accountSource, string userName)
        {
            switch (accountSource)
            {
            case DevAccountSource.WindowsDevCenter:
                return(new AdalAuthContext(userName));

            case DevAccountSource.XboxDeveloperPortal:
                throw new ArgumentException("XDP is no longer a supported developer type. Sign in with a Windows Developer Center account.");

            default:
                throw new ArgumentException("Unsupported developer type");
            }
        }
Exemplo n.º 8
0
        protected override void ProcessRecord()
        {
            try
            {
                DevAccountSource accountType = DevAccountSource.UniversalDeveloperCenter;
                if (AccountSource.Equals("XboxDeveloperPortal", StringComparison.OrdinalIgnoreCase) || AccountSource.Equals("XDP", StringComparison.OrdinalIgnoreCase))
                {
                    accountType = DevAccountSource.XboxDeveloperPortal;
                }
                DevAccount account = Microsoft.Xbox.Services.Tool.Auth.SignIn(accountType, UserName).Result;

                WriteObject(account);
            }
            catch (AggregateException e)
            {
                var innerEx = e.InnerException;
                WriteError(new ErrorRecord(innerEx, "Set-XBLDevUdcAccount failed", ErrorCategory.SecurityError, null));
            }
        }
 private async Task <DevAccount> SignInAsync(DevAccountSource accountSource, string userName)
 {
     return(await ToolAuthentication.SignInAsync(accountSource, userName, this.authMock.Object));
 }
Exemplo n.º 10
0
        public static string GetCacheKey(string userName, DevAccountSource accountSource, string scid, IEnumerable <string> sandboxes)
        {
            string keyFullstring = userName + accountSource.ToString() + scid + (sandboxes == null? string.Empty : string.Join(" ", sandboxes));

            return(keyFullstring.GetHashCode().ToString());
        }
Exemplo n.º 11
0
        public static string GetCacheKey(string userName, DevAccountSource accountSource, string tenant, string scid, string sandbox)
        {
            string keyFullstring = userName + accountSource.ToString() + tenant + scid + sandbox;

            return(keyFullstring.GetHashCode().ToString());
        }
Exemplo n.º 12
0
 public static string GetCacheKey(string userName, DevAccountSource accountSource, string tenant, string scid, IEnumerable <string> sandboxes)
 {
     return(GetCacheKey(userName, accountSource, tenant, scid, sandboxes == null? string.Empty : string.Join(" ", sandboxes)));
 }