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

Allow extra headers #2971

Open
kliem opened this issue May 15, 2024 · 2 comments · May be fixed by #2987
Open

Allow extra headers #2971

kliem opened this issue May 15, 2024 · 2 comments · May be fixed by #2987

Comments

@kliem
Copy link

kliem commented May 15, 2024

I need to call my github instance with additional custom headers.

E.g. there are authorizations methods that use other headers than Authorization.

@EnricoMi
Copy link
Collaborator

EnricoMi commented May 31, 2024

This is not possible right now.

Given these headers are specifically need for authorization, the use of Auth should be refactored for your use case.

Instead of (in Requester)

        if self.__auth is not None:
            requestHeaders["Authorization"] = f"{self.__auth.token_type} {self.__auth.token}"

the Auth should integrate like

        if self.__auth is not None:
            self.__auth.authenticate(requestHeaders)

where default implementation would be

    def authenticate(headers):
        headers["Authorization"] = f"{self.__auth.token_type} {self.__auth.token}"

You could then implement your own Auth setting any header that you need for authentication.

Could be combined with #2811

        if self.__auth is not None:
            self.__auth.authenticate(session)

@kliem kliem linked a pull request Jun 7, 2024 that will close this issue
@kliem
Copy link
Author

kliem commented Jun 7, 2024

Thank you @EnricoMi for your comments. I think I implemented it as you described. I also moved the masking for logging into the Auth class.

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

Successfully merging a pull request may close this issue.

2 participants