Skip to content

Add custom HTTP headers support to authentication flows#145

Open
rikvanduijn wants to merge 2 commits intodirkjanm:masterfrom
rikvanduijn:headers
Open

Add custom HTTP headers support to authentication flows#145
rikvanduijn wants to merge 2 commits intodirkjanm:masterfrom
rikvanduijn:headers

Conversation

@rikvanduijn
Copy link
Contributor

Summary

This PR adds support for custom HTTP headers in ROADtools authentication flows. Users can now specify custom headers that will be included in all HTTP requests made during authentication and API operations.

Changes

roadlib (roadtools/roadlib/auth.py):

  • Added custom_headers attribute to the Authentication class to store custom headers
  • Added set_custom_headers() method to configure custom headers from a dictionary
  • Added --headers command-line argument that accepts JSON-formatted headers
  • Modified all HTTP request methods (requests_get, requests_post, requests_put, requests_patch, requests_delete) to include custom headers in their requests
  • Added JSON parsing logic in parse_args() to handle the --headers argument with error handling for invalid JSON

roadtx (roadtools/roadtx/main.py):

  • Added --headers argument to the refreshtokento subcommand
  • Added --headers argument to the interactiveauth subcommand

Use Case

This feature enables users to pass custom HTTP headers like X-AnchorMailbox used by for example PIM authentication flow.

Usage Example
roadtx gettokens --headers '{"X-AnchorMailbox": "Oid:objectid@tenantid"}'

Copy link
Owner

@dirkjanm dirkjanm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems some artifacts of the merge are still in the code, if you can clean that up I can merge the PR. great addition!

"""
self.user_agent = self.lookup_user_agent(useragent)

<<<<<<< Updated upstream
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix these artifacts? :)

"""
if headers_dict:
self.custom_headers = headers_dict
>>>>>>> Stashed changes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and these

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes my changes were done so long a go. Was running way behind on your version. Will make sure to fix em!

@rikvanduijn
Copy link
Contributor Author

Ive removed the artifacts

@olafhartong
Copy link

Did you do it or your assistant ? ;)

@rikvanduijn
Copy link
Contributor Author

Did you do it or your assistant ? ;)

IMG_1341

@olafhartong
Copy link

image

@jdye64
Copy link

jdye64 commented Feb 12, 2026

I'm saving this thread. Good job to the both of you. Never thought I'd live to see the day that memes ended up in PR reviews but this made me laugh!

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 this pull request may close these issues.

4 participants