public virtual void SignRequest(HttpRequestMessage request, OAuth2HttpRequestSigningMethod signingMethod, string tokenQueryKey)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            switch (signingMethod)
            {
            case OAuth2HttpRequestSigningMethod.AuthorizationHeader:
                request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(TokenType, AccessToken);
                break;

            case OAuth2HttpRequestSigningMethod.UrlQuery:
                request.RequestUri = new Uri(request.RequestUri.ToString() + (String.IsNullOrEmpty(request.RequestUri.Query) ? "?" : "&") + (tokenQueryKey ?? "access_token") + "=" + Uri.EscapeDataString(this.AccessToken));
                break;

            default:
                throw new NotSupportedException("Unsupported signing method for OAuth 2.0 token.");
            }
        }
Ejemplo n.º 2
0
 private bool ShouldAuthoriseRequest(HttpRequestMessage request, OAuth2HttpRequestSigningMethod signingMethod)
 {
     return(((signingMethod == OAuth2HttpRequestSigningMethod.AuthorizationHeader && IsAuthHeaderMissing(request.Headers.Authorization)) ||
             (signingMethod == OAuth2HttpRequestSigningMethod.UrlQuery && IsAccessTokenQueryArgumentMissing(request.RequestUri))) &&
            (_RequestCondition?.ShouldProcess(request) ?? true));
 }
Ejemplo n.º 3
0
 public virtual void SignRequest(HttpRequestMessage request, OAuth2HttpRequestSigningMethod signingMethod)
 {
     Helper.Throw();
 }