示例#1
0
 /// <summary>
 /// Check if the specified Authorization Token is still valid, and if it is collect required information to login.
 /// </summary>
 /// <param name="email">The Email of the account</param>
 /// <param name="token">The Master Authorization Token, if left null will use the Authorization Token associated to this <see cref="MobileClient"/> (If specified in constructor)</param>
 /// <returns></returns>
 public async Task <bool> LoginWithToken(string email, string token = null)
 {
     Debug.WriteLine($"Attempting Login ({email})...");
     try
     {
         Session = new MobileSession(new UserDetails(email, "", GoogleAuth.GetDeviceId()));
         return(await Session.LoginAsync(token));
     }
     catch (HttpRequestException)
     {
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// Login to Google Play Music with the specified email and password.
        /// This will make two requests to the Google Authorization Server, and collect an Authorization Token to use for all requests.
        /// </summary>
        /// <param name="email">The Email / Username of the google account</param>
        /// <param name="password">The Password / App Specific password (https://security.google.com/settings/security/apppasswords)</param>
        public sealed override async Task <bool> LoginAsync(string email, string password)
        {
            try
            {
                Debug.WriteLine($"Attempting Login ({email})...");

                Session = new MobileSession(new UserDetails(email, password, GoogleAuth.GetDeviceId()));
                var status = await Session.LoginAsync();

                if (!status)
                {
                    Debug.WriteLine("Login Failed.");
                    return(false);
                }
                Debug.WriteLine("Login Success!");
                return(true);
            }
            catch (HttpRequestException)
            {
                return(false);
            }
        }