/// <summary> /// Create a HttpMessageHandler which handles the OAuth communication for you /// </summary> /// <param name="oAuth1Settings">OAuth1Settings</param> /// <param name="oAuth1HttpBehaviour">OAuth1HttpBehaviour</param> /// <param name="innerHandler">HttpMessageHandler</param> public OAuth1HttpMessageHandler(OAuth1Settings oAuth1Settings, OAuth1HttpBehaviour oAuth1HttpBehaviour, HttpMessageHandler innerHandler) : base(innerHandler) { if (oAuth1Settings.ClientId is null) { throw new ArgumentNullException(nameof(oAuth1Settings.ClientId)); } if (oAuth1Settings.SignatureType == OAuth1SignatureTypes.RsaSha1) { if (oAuth1Settings.RsaSha1Provider is null) { throw new ArgumentNullException(nameof(oAuth1Settings.RsaSha1Provider)); } } else if (oAuth1Settings.ClientSecret is null) { throw new ArgumentNullException(nameof(oAuth1Settings.ClientSecret)); } if (oAuth1Settings.TokenUrl is null) { throw new ArgumentNullException(nameof(oAuth1Settings.TokenUrl)); } _oAuth1Settings = oAuth1Settings; var newHttpBehaviour = oAuth1HttpBehaviour.ShallowClone(); // Remove the OnHttpMessageHandlerCreated newHttpBehaviour.OnHttpMessageHandlerCreated = null; // Use it for internal communication _oAuth1HttpBehaviour = (OAuth1HttpBehaviour)newHttpBehaviour; }
/// <inheritdoc /> public IChangeableHttpBehaviour ShallowClone() { // the wrapper object will be clone when creating the OAuth1HttpBehaviour var result = new OAuth1HttpBehaviour(_wrapped) { OnAccessTokenValues = OnAccessTokenValues, BeforeSend = BeforeSend }; return(result); }
/// <inheritdoc /> public IChangeableHttpBehaviour ShallowClone() { // the wrapper object will be clone when creating the OAuth1HttpBehaviour var result = new OAuth1HttpBehaviour(_wrapped) { OnAccessTokenValues = OnAccessTokenValues, BeforeSend = BeforeSend }; return result; }