Esempio n. 1
0
File: OAuth.cs Progetto: uyitroa/osu
        internal bool AuthenticateWithLogin(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(password))
            {
                return(false);
            }

            using (var req = new AccessTokenRequestPassword(username, password)
            {
                Url = $@"{endpoint}/oauth/token",
                Method = HttpMethod.POST,
                ClientId = clientId,
                ClientSecret = clientSecret
            })
            {
                try
                {
                    req.Perform();
                }
                catch
                {
                    return(false);
                }

                Token = req.ResponseObject;
                return(true);
            }
        }
Esempio n. 2
0
        internal bool AuthenticateWithLogin(string username, string password)
        {
            var req = new AccessTokenRequestPassword(username, password)
            {
                Url          = $@"{endpoint}/oauth/access_token",
                Method       = HttpMethod.POST,
                ClientId     = clientId,
                ClientSecret = clientSecret
            };

            try
            {
                req.BlockingPerform();
            }
            catch
            {
                return(false);
            }

            Token = req.ResponseObject;
            return(true);
        }