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


C# AuthorizationState.Delete方法代码示例

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


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

示例1: ExchangeUserCredentialForToken

		/// <summary>
		/// Exchanges a resource owner's password credential for OAuth 2.0 refresh and access tokens.
		/// </summary>
		/// <param name="userName">The resource owner's username, as it is known by the authorization server.</param>
		/// <param name="password">The resource owner's account password.</param>
		/// <param name="scopes">The desired scope of access.</param>
		/// <returns>The result, containing the tokens if successful.</returns>
		public IAuthorizationState ExchangeUserCredentialForToken(string userName, string password, IEnumerable<string> scopes = null) {
			Requires.NotNullOrEmpty(userName, "userName");
			Requires.NotNull(password, "password");

			var authorizationState = new AuthorizationState(scopes);

			var request = new AccessTokenResourceOwnerPasswordCredentialsRequest(this.AuthorizationServer.TokenEndpoint, this.AuthorizationServer.Version) {
				ClientIdentifier = this.ClientIdentifier,
				ClientSecret = this.ClientSecret,
				UserName = userName,
				Password = password,
			};

			var response = this.Channel.Request(request);
			var success = response as AccessTokenSuccessResponse;
			var failure = response as AccessTokenFailedResponse;
			ErrorUtilities.VerifyProtocol(success != null || failure != null, MessagingStrings.UnexpectedMessageReceivedOfMany);
			if (success != null) {
				UpdateAuthorizationWithResponse(authorizationState, success);
			} else { // failure
				Logger.OAuth.Info("Resource Owner credentials rejected by the Authorization Server.");
				authorizationState.Delete();
			}

			return authorizationState;
		}
开发者ID:SachiraChin,项目名称:dotnetopenid,代码行数:33,代码来源:ClientBase.cs

示例2: RequestAccessTokenAsync

		/// <summary>
		/// Requests an access token using a partially .initialized request message.
		/// </summary>
		/// <param name="request">The request message.</param>
		/// <param name="scopes">The scopes requested by the client.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// The result of the request.
		/// </returns>
		private async Task<IAuthorizationState> RequestAccessTokenAsync(ScopedAccessTokenRequest request, IEnumerable<string> scopes, CancellationToken cancellationToken) {
			Requires.NotNull(request, "request");

			var authorizationState = new AuthorizationState(scopes);

			request.ClientIdentifier = this.ClientIdentifier;
			this.ApplyClientCredential(request);
			request.Scope.UnionWith(authorizationState.Scope);

			var response = await this.Channel.RequestAsync(request, cancellationToken);
			var success = response as AccessTokenSuccessResponse;
			var failure = response as AccessTokenFailedResponse;
			ErrorUtilities.VerifyProtocol(success != null || failure != null, MessagingStrings.UnexpectedMessageReceivedOfMany);
			if (success != null) {
				authorizationState.Scope.Clear(); // clear the scope we requested so that the response will repopulate it.
				UpdateAuthorizationWithResponse(authorizationState, success);
			} else { // failure
				Logger.OAuth.Info("Credentials rejected by the Authorization Server.");
				authorizationState.Delete();
			}

			return authorizationState;
		}
开发者ID:Crypth,项目名称:DotNetOpenAuth,代码行数:32,代码来源:ClientBase.cs

示例3: RequestAccessToken

		/// <summary>
		/// Requests an access token using a partially .initialized request message.
		/// </summary>
		/// <param name="request">The request message.</param>
		/// <param name="scopes">The scopes requested by the client.</param>
		/// <returns>The result of the request.</returns>
		private IAuthorizationState RequestAccessToken(ScopedAccessTokenRequest request, IEnumerable<string> scopes = null) {
			Requires.NotNull(request, "request");

			var authorizationState = new AuthorizationState(scopes);

			request.ClientIdentifier = this.ClientIdentifier;
			request.ClientSecret = this.ClientSecret;
			request.Scope.UnionWith(authorizationState.Scope);

			var response = this.Channel.Request(request);
			var success = response as AccessTokenSuccessResponse;
			var failure = response as AccessTokenFailedResponse;
			ErrorUtilities.VerifyProtocol(success != null || failure != null, MessagingStrings.UnexpectedMessageReceivedOfMany);
			if (success != null) {
				UpdateAuthorizationWithResponse(authorizationState, success);
			} else { // failure
				Logger.OAuth.Info("Credentials rejected by the Authorization Server.");
				authorizationState.Delete();
			}

			return authorizationState;
		}
开发者ID:jorgemuza,项目名称:dotnetopenid,代码行数:28,代码来源:ClientBase.cs


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