示例#1
0
        public AccessToken RequestAccessToken(string code, Uri redirectUri)
        {
            RedirectUri = redirectUri.ToString();

            if (_AccessToken != null)
            {
                return(_AccessToken);
            }

            if (string.IsNullOrEmpty(code))
            {
                throw new Exception("Required authorization code.");
            }

            if (redirectUri == null)
            {
                throw new Exception("Required redirect uri.");
            }

            if (!UriUtilities.IsHttps(redirectUri))
            {
                throw new Exception("Redirect uri must be secure connection(https).");
            }

            return(GetAccessToken(code, redirectUri.ToString()));
        }
示例#2
0
        public Uri GetAuthorizationUrl(Uri redirectUri, string[] scopes)
        {
            string Scopes = string.Empty;

            if (scopes != null && scopes.Length != 0)
            {
                Scopes = string.Join(",", scopes);
            }
            else
            {
                Scopes = "full";
            }

            if (redirectUri == null)
            {
                throw new Exception("Required redirect uri.");
            }

            if (!UriUtilities.IsHttps(redirectUri))
            {
                throw new Exception("Redirect uri must be secure connection(https).");
            }

            return(new Uri(GetAuthorizationUrl(redirectUri.ToString(), Scopes)));
        }