当前位置: 首页>>代码示例>>C#>>正文


C# UriBuilder.AppendQueryArgument方法代码示例

本文整理汇总了C#中System.UriBuilder.AppendQueryArgument方法的典型用法代码示例。如果您正苦于以下问题:C# UriBuilder.AppendQueryArgument方法的具体用法?C# UriBuilder.AppendQueryArgument怎么用?C# UriBuilder.AppendQueryArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.UriBuilder的用法示例。


在下文中一共展示了UriBuilder.AppendQueryArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetServiceLoginUrl

 protected override Uri GetServiceLoginUrl(Uri returnUrl) {
     var builder = new UriBuilder(Endpoints.Authorization);
     builder.AppendQueryArgument("response_type", "code");
     builder.AppendQueryArgument("client_id", ClientId);
     builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
     return builder.Uri;
 }
开发者ID:yilmazyavuz,项目名称:dotNet-SDK,代码行数:7,代码来源:BulutfonWebClient.cs

示例2: QueryAccessToken

        protected override string QueryAccessToken(Uri returnUrl, string authorizationCode)
        {
            var builder = new UriBuilder(TokenEndpoint);
            builder.AppendQueryArgument("client_id", this.appId);
            builder.AppendQueryArgument("client_secret", this.clientSecret);
            builder.AppendQueryArgument("code", authorizationCode);
            var redirectUri = NormalizeHexEncoding(returnUrl.AbsoluteUri);
            builder.AppendQueryArgument("redirect_uri", redirectUri);

            //builder.AppendQueryArgument("grant_type", "client_credentials");

            using (WebClient client = new WebClient())
            {
                string data = client.DownloadString(builder.Uri);
                if (string.IsNullOrEmpty(data))
                {
                    return null;
                }

                JObject dataObject = JObject.Parse(data);

                //TODO: Проверять успешность запроса
                var accessToken = dataObject["access_token"].ToString();
                var userId = (int)dataObject["user_id"];

                HttpContext.Current.Session[accessToken] = Convert.ToString(userId);
                return accessToken;
            }
        }
开发者ID:tssoft,项目名称:TsSoft.OpenAuth,代码行数:29,代码来源:VkClient.cs

示例3: GetUserData

        protected override IDictionary<string, string> GetUserData(string accessToken)
        {
            var url = ApiEndpoint + "users.get";
            var builder = new UriBuilder(url);
            builder.AppendQueryArgument("access_token", accessToken);
            var userId = Convert.ToString(HttpContext.Current.Session[accessToken]);
            if (!string.IsNullOrWhiteSpace(userId))
            {
                builder.AppendQueryArgument("uids", userId);
            }
            using (WebClient client = new WebClient())
            {
                client.Encoding = Encoding.UTF8;
                string data = client.DownloadString(builder.Uri);
                if (string.IsNullOrEmpty(data))
                {
                    return null;
                }

                dynamic jsonResult = JObject.Parse(data);

                //TODO: Проверять успешность запроса
                var userData = new Dictionary<string, string>();
                userData.Add("id", Convert.ToString(jsonResult.response[0].uid));
                userData.Add("username", Convert.ToString(jsonResult.response[0].uid));
                userData.Add("name", string.Format("{0} {1}",
                    Convert.ToString(jsonResult.response[0].first_name),
                    Convert.ToString(jsonResult.response[0].last_name)));
                return userData;
            }
        }
开发者ID:tssoft,项目名称:TsSoft.OpenAuth,代码行数:31,代码来源:VkClient.cs

示例4: GetServiceLoginUrl

        /// <summary>
        /// Gets the full url pointing to the login page for this client. The url should include the specified return url so that when the login completes, user is redirected back to that url.
        /// </summary>
        /// <param name="returnUrl">The return URL.</param>
        /// <returns>
        /// An absolute URL.
        /// </returns>
        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            var uriBuilder = new UriBuilder(AuthorizeUrl);
            uriBuilder.AppendQueryArgument("client_id", this.clientId);
            uriBuilder.AppendQueryArgument("redirect_uri", returnUrl.ToString());

            return uriBuilder.Uri;
        }
开发者ID:ErikSchierboom,项目名称:CustomOAuthClient,代码行数:15,代码来源:GitHubClient.cs

示例5: GetServiceLoginUrl

        /// <summary>
        /// The get service login url.
        /// </summary>
        /// <param name="returnUrl">
        /// The return url.
        /// </param>
        /// <returns>An absolute URI.</returns>
        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            var builder = new UriBuilder(_authorizationEndpoint);

            builder.AppendQueryArgument("client_id", _appId);
            builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);

            return builder.Uri;
        }
开发者ID:philpursglove,项目名称:DDDEastAnglia,代码行数:16,代码来源:GitHubOAuthClient.cs

示例6: GetServiceLoginUrl

 protected override Uri GetServiceLoginUrl(Uri returnUrl)
 {
     var builder = new UriBuilder(AuthorizationEndpoint);
     builder.AppendQueryArgument("client_id", this.appId);
     builder.AppendQueryArgument("scope", "groups, wall");
     builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
     builder.AppendQueryArgument("display", "page");
     return builder.Uri;
 }
开发者ID:tssoft,项目名称:TsSoft.OpenAuth,代码行数:9,代码来源:VkClient.cs

示例7: GetServiceLoginUrlInternal

        internal Uri GetServiceLoginUrlInternal(Uri returnUrl)
        {
            UriBuilder uriBuilder = new UriBuilder(AuthorizationEndpoint);
            uriBuilder.AppendQueryArgument("client_id", _clientID);
            uriBuilder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
            //uriBuilder.AppendQueryArgument("scope", "user");

            return uriBuilder.Uri;
        }
开发者ID:paulirwin,项目名称:DevAuth.AspNet,代码行数:9,代码来源:GitHubAuthenticationClient.cs

示例8: GetServiceLoginUrl

        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            var builder = new UriBuilder(AUTHORIZATION_ENDPOINT);

            builder.AppendQueryArgument("client_id", _appId);
            builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
            builder.AppendQueryArgument("scope", "user:email");

            return builder.Uri;
        }
开发者ID:BookSwapSteve,项目名称:Exceptionless,代码行数:10,代码来源:GitHubClient.cs

示例9: GetServiceLoginUrl

        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            UriBuilder uriBuilder = new UriBuilder(AuthorizationEndpoint);
            uriBuilder.AppendQueryArgument("client_id", this.clientId);
            uriBuilder.AppendQueryArgument("redirect_uri", returnUrl.GetLeftPart(UriPartial.Path));
            uriBuilder.AppendQueryArgument("response_type", "code");
            uriBuilder.AppendQueryArgument("scope", "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email");
            uriBuilder.AppendQueryArgument("state", returnUrl.Query.Substring(1));

            return uriBuilder.Uri;
        }
开发者ID:NethmiHettiarachchi,项目名称:ASP.Net-MVC-4-Simple-loggin,代码行数:11,代码来源:GooglePlusClient.cs

示例10: GetServiceLoginUrl

        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            UriBuilder builder = new UriBuilder(AuthorizationEndpoint);
            builder.AppendQueryArgument("client_id", ApplicationId);
            builder.AppendQueryArgument("response_type", "code");
            builder.AppendQueryArgument("scope", Scope);
            builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
            builder.AppendQueryArgument("nonce", Guid.NewGuid().ToString().Replace("-", ""));

            return builder.Uri;
        }
开发者ID:radiantlogicinc,项目名称:.NET-Clients-for-CFS,代码行数:11,代码来源:OpenIdConnectClient.cs

示例11: GetServiceLoginUrl

        /// <summary>
        /// The get service login url.
        /// </summary>
        /// <param name="returnUrl">
        /// The return url.
        /// </param>
        /// <returns>An absolute URI.</returns>
        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            // Note: Facebook doesn't like us to url-encode the redirect_uri value
            var builder = new UriBuilder(AuthorizationEndpoint);

            builder.AppendQueryArgument("client_id",this.appId);
            builder.AppendQueryArgument("redirect_uri", returnUrl.AbsoluteUri);
            builder.AppendQueryArgument("scope", this.scope);
            builder.AppendQueryArgument("response_type", "code");

            return builder.Uri;
        }
开发者ID:unconnected4,项目名称:DotNetOpenAuth.VkClient,代码行数:19,代码来源:VkClient.cs

示例12: GetUserData

        protected override IDictionary<string, string> GetUserData(string accessToken)
        {
            UriBuilder uriBuilder = new UriBuilder(UserInfoEndpoint);
            uriBuilder.AppendQueryArgument("access_token", accessToken);

            WebRequest webRequest = WebRequest.Create(uriBuilder.Uri);
            using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
            {
                if (webResponse.StatusCode == HttpStatusCode.OK)
                {
                    using (var responseStream = webResponse.GetResponseStream())
                    {
                        if (responseStream == null)
                            return null;

                        StreamReader streamReader = new StreamReader(responseStream);

                        Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(streamReader.ReadToEnd());

                        // Add a username field in the dictionary
                        if (values.ContainsKey("email") && !values.ContainsKey("username"))
                            values.Add("username", values["email"]);

                        return values;
                    }
                }
            }

            return null;
        }
开发者ID:ABDFath,项目名称:GESTACAJOU,代码行数:30,代码来源:GoogleAuthMe.cs

示例13: GetUserData

        protected override IDictionary<string, string> GetUserData(string accessToken)
        {
            var client = new RestClient();

            var builder = new UriBuilder(UsersEndpoint);

            builder.AppendQueryArgument("access_token", accessToken);

            var request = new RestRequest(builder.Uri.AbsoluteUri, Method.GET);

            var response = client.Execute(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
                return new Dictionary<string, string>();

            var json = JObject.Parse(response.Content);

            var strs = new Dictionary<string, string>();

            strs["id"] = json["id"].ToString();
            strs["username"] = json["login"].ToString();

            try
            {
                strs["name"] = json["name"].ToString();
            }
            catch
            {
            }

            return strs;
        }
开发者ID:paulirwin,项目名称:DevAuth.AspNet,代码行数:32,代码来源:GitHubAuthenticationClient.cs

示例14: Authorize

		public ActionResult Authorize() {
			var incomingAuthzRequest = this.authorizationServer.ReadAuthorizationRequest(this.Request);
			if (incomingAuthzRequest == null) {
				return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Missing authorization request");
			}

			var returnTo = new UriBuilder(this.Url.AbsoluteAction("AuthorizeWithMicrosoftAccount"));
			returnTo.AppendQueryArgument("nestedAuth", this.Request.Url.Query);
			var scopes = new[] { "wl.signin", "wl.basic", "wl.emails" }; // this is a subset of what the client app asks for, ensuring automatic approval.
			return LiveConnectClient.PrepareRequestUserAuthorization(scopes, returnTo.Uri).AsActionResult();
		}
开发者ID:raam030,项目名称:IronPigeon,代码行数:11,代码来源:OAuthController.cs

示例15: GetUserData

        /// <summary>
        /// Given the access token, gets the logged-in user's data. The returned dictionary must include two keys 'id', and 'username'.
        /// </summary>
        /// <param name="accessToken">The access token of the current user.</param>
        /// <returns>
        /// A dictionary contains key-value pairs of user data
        /// </returns>
        protected override IDictionary<string, string> GetUserData(string accessToken)
        {
            using (var webClient = CreateWebClient())
            {
                var uriBuilder = new UriBuilder(ProfileUrl);
                uriBuilder.AppendQueryArgument("access_token", accessToken);

                var profileResponse = webClient.DownloadString(uriBuilder.Uri);
                var profile = JsonConvert.DeserializeObject<dynamic>(profileResponse);

                return new Dictionary<string, string>
                       {
                           { "login", profile.login.ToString() },
                           { "id", profile.id.ToString() },
                           { "avatar_url", profile.avatar_url.ToString() },
                           { "gravatar_id", profile.gravatar_id.ToString() },
                           { "url", profile.url.ToString() },
                           { "name", profile.name.ToString() },
                           { "company", profile.company.ToString() },
                           { "blog", profile.blog.ToString() },
                           { "location", profile.location.ToString() },
                           { "email", profile.email.ToString() },
                           { "hireable", profile.hireable.ToString() },
                           { "bio", profile.bio.ToString() },
                           { "public_repos", profile.public_repos.ToString() },
                           { "public_gists", profile.public_gists.ToString() },
                           { "followers", profile.followers.ToString() },
                           { "following", profile.following.ToString() },
                           { "html_url", profile.html_url.ToString() },
                           { "created_at", profile.created_at.ToString() },
                           { "type", profile.type.ToString() },
                           { "total_private_repos", profile.total_private_repos.ToString() },
                           { "owned_private_repos", profile.owned_private_repos.ToString() },
                           { "private_gists", profile.private_gists.ToString() },
                           { "disk_usage", profile.disk_usage.ToString() },
                           { "collaborators", profile.collaborators.ToString() },
                           { "plan_name", profile.plan.name.ToString() },
                           { "plan_space", profile.plan.space.ToString() },
                           { "plan_collaborators", profile.plan.collaborators.ToString() },
                           { "plan_private_repos", profile.plan.private_repos.ToString() }
                       };
            }
        }
开发者ID:ErikSchierboom,项目名称:CustomOAuthClient,代码行数:50,代码来源:GitHubClient.cs


注:本文中的System.UriBuilder.AppendQueryArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。