Esempio n. 1
0
        /// <summary>
        /// Build Authorization URI.
        /// </summary>
        /// <param name="redirectUri">Client redirect URI (URL encoded)</param>
        /// <param name="tag">Identifying tag. This tag will be transmitted both sent link and callback link.</param>
        /// <param name="scope">Access scope option.</param>
        /// <returns>Generated user authorization link.</returns>
        public Uri BuildLink(Uri redirectUri, string tag, AuthorizationScope scope)
        {
            var sb = new StringBuilder($"{RequestLink}?");

            string responseType = "code";

            sb.Append($"response_type={responseType}");
            sb.Append($"&client_id={_clientId}");
            sb.Append($"&redirect_uri={redirectUri.AbsoluteUri}");
            sb.Append($"&state={tag}");
            sb.Append($"&scope={string.Join(" ", scope.GetRequestArray())}");

            return(new Uri(sb.ToString()));
        }
Esempio n. 2
0
        /// <summary>
        /// Build Authorization URI.
        /// </summary>
        /// <param name="state">Identifying tag. This tag will be transmitted both sent link and callback link.</param>
        /// <param name="scope">Access scope option.</param>
        /// <returns>Generated user authorization link.</returns>
        public Uri BuildAuthorizationLink(string state, AuthorizationScope scope)
        {
            var sb = new StringBuilder($"{AuthorizationLink}?");

            string responseType = "code";

            sb.Append($"client_id={_clientId}");
            sb.Append($"&redirect_uri={HttpUtility.UrlEncode(_registeredRedirectUri.OriginalString)}");
            sb.Append($"&response_type={responseType}");
            sb.Append($"&scope={HttpUtility.UrlEncode(string.Join(" ", scope.GetRequestArray()))}");
            sb.Append($"&state={HttpUtility.UrlEncode(state)}");

            return(new Uri(sb.ToString()));
        }