本文整理汇总了C#中QueryParameters.HasName方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParameters.HasName方法的具体用法?C# QueryParameters.HasName怎么用?C# QueryParameters.HasName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryParameters
的用法示例。
在下文中一共展示了QueryParameters.HasName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAuthorizationCode
public void HandleAuthorizationCode(QueryParameters responseCollection)
{
if (responseCollection.HasName("code"))
{
ConnectionToken.Code = responseCollection["code"];
logger.Info("User successfully logged in and returned with Authorization code");
}
else if (responseCollection.ToList().Exists(x => x.Key.ToLower().Contains("denied") || x.Value.ToLower().Contains("denied")))
{
logger.Error(ErrorMessages.UserDeniedAccess(provider.ProviderType, responseCollection));
throw new UserDeniedPermissionException(provider.ProviderType);
}
else
{
logger.Error(ErrorMessages.UserLoginResponseError(provider.ProviderType, responseCollection));
throw new OAuthException(ErrorMessages.UserLoginResponseError(provider.ProviderType, responseCollection));
}
}
示例2: HandleAccessTokenResponse
public void HandleAccessTokenResponse(QueryParameters responseCollection)
{
if (responseCollection.HasName("oauth_token_secret") || string.IsNullOrEmpty(provider.GetScope()))
{
ConnectionToken.AccessToken = responseCollection["oauth_token"];
ConnectionToken.TokenSecret = responseCollection["oauth_token_secret"];
ConnectionToken.ResponseCollection.AddRange(responseCollection, true);
isSuccess = true;
logger.Info("Access Token Successfully Received");
}
else
{
logger.Error(ErrorMessages.AccessTokenResponseInvalid(responseCollection));
throw new OAuthException(ErrorMessages.AccessTokenResponseInvalid(responseCollection));
}
}
示例3: HandleRequestToken
public void HandleRequestToken(QueryParameters responseCollection)
{
//In Hybrid protocol, OAuth may not be necessary. In such case flow ends
//But some providers may have scope black as scope is defined at provider directly (like Yahoo)
if (responseCollection.HasName("openid.mode"))
{
if (responseCollection["openid.mode"].Contains("cancel"))
throw new UserDeniedPermissionException(provider.ProviderType);
}
if (!string.IsNullOrEmpty(provider.GetScope()) || provider.IsScopeDefinedAtProvider)
if (responseCollection.HasName("openid.oauth.request_token"))
ConnectionToken.RequestToken = responseCollection["openid.oauth.request_token"];
else if (responseCollection.HasName("openid.ext2.request_token"))
ConnectionToken.RequestToken = responseCollection["openid.ext2.request_token"];
else
{
logger.Error(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
throw new OAuthException(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
}
QueryParameters openIDValues = new QueryParameters();
if (responseCollection.HasName("openid.ns.ext1"))
{
if (responseCollection.HasName("openid.ext1.value.email"))
openIDValues.Add(new QueryParameter("openid.ext1.value.email", responseCollection["openid.ext1.value.email"]));
if (responseCollection.HasName("openid.ext1.value.firstname"))
openIDValues.Add(new QueryParameter("openid.ext1.value.firstname", responseCollection["openid.ext1.value.firstname"]));
if (responseCollection.HasName("openid.ext1.value.lastname"))
openIDValues.Add(new QueryParameter("openid.ext1.value.lastname", responseCollection["openid.ext1.value.lastname"]));
if (responseCollection.HasName("openid.ext1.value.language"))
openIDValues.Add(new QueryParameter("openid.ext1.value.language", responseCollection["openid.ext1.value.language"]));
if (responseCollection.HasName("openid.ext1.value.country"))
openIDValues.Add(new QueryParameter("openid.ext1.value.country", responseCollection["openid.ext1.value.country"]));
if (responseCollection.HasName("openid.identity"))
openIDValues.Add(new QueryParameter("openid.identity", responseCollection["openid.identity"]));
ConnectionToken.ResponseCollection.AddRange(openIDValues, true);
}
else if (responseCollection.HasName("openid.ns.ax"))
{
if (responseCollection.HasName("openid.ax.value.email"))
openIDValues.Add(new QueryParameter("openid.ax.value.email", responseCollection["openid.ax.value.email"]));
if (responseCollection.HasName("openid.ax.value.firstname"))
openIDValues.Add(new QueryParameter("openid.ax.value.firstname", responseCollection["openid.ax.value.firstname"]));
if (responseCollection.HasName("openid.ax.value.lastname"))
openIDValues.Add(new QueryParameter("openid.ax.value.lastname", responseCollection["openid.ax.value.lastname"]));
if (responseCollection.HasName("openid.ax.value.language"))
openIDValues.Add(new QueryParameter("openid.ax.value.language", responseCollection["openid.ax.value.language"]));
if (responseCollection.HasName("openid.ax.value.country"))
openIDValues.Add(new QueryParameter("openid.ax.value.country", responseCollection["openid.ax.value.country"]));
ConnectionToken.ResponseCollection.AddRange(openIDValues, true);
}
logger.Info("User successfully logged in and returned with Authorization Token");
}
示例4: HandleAccessTokenResponse
public void HandleAccessTokenResponse(QueryParameters responseCollection)
{
if (responseCollection.HasName("oauth_token_secret"))
{
connectionToken.AccessToken = responseCollection["oauth_token"];
connectionToken.TokenSecret = responseCollection["oauth_token_secret"];
connectionToken.ResponseCollection.AddRange(responseCollection, true);
isSuccess = true;
logger.Info("Access token successfully received");
}
else
{
logger.Error(ErrorMessages.AccessTokenResponseInvalid(responseCollection));
throw new OAuthException(ErrorMessages.AccessTokenResponseInvalid(responseCollection));
}
}
示例5: HandleUserReturnCallback
public void HandleUserReturnCallback(QueryParameters responseCollection)
{
if (responseCollection.HasName("oauth_verifier"))
{
connectionToken.OauthVerifier = responseCollection["oauth_verifier"];
connectionToken.AuthorizationToken = responseCollection["oauth_token"];
logger.Info("User successfully logged in and returned");
}
else if (responseCollection.ToList().Exists(x => x.Key.ToLower().Contains("denied") || x.Value.ToLower().Contains("denied")))
{
logger.Error(ErrorMessages.UserDeniedAccess(connectionToken.Provider, responseCollection));
throw new OAuthException(ErrorMessages.UserDeniedAccess(connectionToken.Provider, responseCollection));
}
else
{
logger.Error(ErrorMessages.UserLoginResponseError(provider.ProviderType, responseCollection));
throw new OAuthException(ErrorMessages.UserLoginResponseError(provider.ProviderType, responseCollection));
}
}
示例6: HandleRequestTokenGrant
public void HandleRequestTokenGrant(QueryParameters responseCollection)
{
if (responseCollection.HasName("oauth_token_secret"))
{
ConnectionToken.RequestToken = responseCollection["oauth_token"];
ConnectionToken.TokenSecret = responseCollection["oauth_token_secret"];
ConnectionToken.ResponseCollection.AddRange(responseCollection, false);
logger.Info("Request Token successfully received");
}
else
{
logger.Error(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
throw new OAuthException(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
}
}