Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include/add headers to WikiSite request #44

Open
WesJM opened this issue Oct 4, 2018 · 3 comments
Open

Include/add headers to WikiSite request #44

WesJM opened this issue Oct 4, 2018 · 3 comments

Comments

@WesJM
Copy link

WesJM commented Oct 4, 2018

I'm trying to access a wiki that uses SAML authentication. Is there a method to include/add headers to a the WikiSite request?

@CXuesong
Copy link
Owner

CXuesong commented Oct 6, 2018

You may want to derive your own implementation from WikiClient class, overriding WikiClient.CreateHttpRequestMessage. For example:

public class MyWikiClient : WikiClient
{

    // ... any class constructors here

    protected override HttpRequestMessage CreateHttpRequestMessage(string endPointUrl, WikiRequestMessage message)
    {
        var httpRequest = base.CreateHttpRequestMessage(endPointUrl, message);
        // Unconditionally adds a header to all the HTTP requests sent to the MediaWiki API endpoint.
        httpRequest.Headers.Add("Header", "Value");
        return httpRequest;
    }

}

Sorry about my lack of SAML authentication knowledge to properly address the situation in the code. While I'm looking for some introductory material for this, perhaps you might get some rough idea from the example above 🌚

Plus,

  • I need to add some documentation on this virtual method. 205a237

@WesJM
Copy link
Author

WesJM commented Oct 9, 2018

No apologies...I truly appreciate all your work for the API.
Thank you for the suggestion and example! :)

@CXuesong
Copy link
Owner

You are welcome. Anyway, I will try to keep this issue updated in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants