Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
Changed default for CONF_API_KEY_HEADER_NAME to "Authorization"
  • Loading branch information
mark1foley authored May 7, 2024
1 parent 690fe3c commit 2860792
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/gtfs_rt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

CONF_API_KEY = "api_key"
CONF_X_API_KEY = "x_api_key"
CONF_API_KEY_HEADER_NAME = "api_key_header"
CONF_API_KEY_HEADER_NAME = "Authorization"
CONF_STOP_ID = "stopid"
CONF_ROUTE = "route"
CONF_DIRECTION_ID = "directionid"
Expand Down

2 comments on commit 2860792

@elffaW
Copy link

@elffaW elffaW commented on 2860792 May 7, 2024

Choose a reason for hiding this comment

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

Hello! I was the author of #31, thanks for merging that. However, I think that this commit introduces some potential confusion. The idea of the CONF_API_KEY_HEADER_NAME is to provide the name of the header to look for to optionally override the value "Authorization" (some APIs require an alternative header name for the API key, e.g., WMATA wants "api_key" per #30). With this commit, it will now look for the header "Authorization" to contain that header name:

With the PR (before this commit), the relevant headers would be:

{
  "api_key_header": "api_key",
  "api_key": "abcd1234",
}

or with the default behavior:

{
  "Authorization": "abcd1234",
}

After this commit, the relevant headers would be:

{
  "Authorization": "api_key",
  "api_key": "abcd1234",
}

(the default behavior is the same as above)

I think that using the same key "Authorization" to mean either the API key value or the custom header name could be confusing. If you understood all this and disagree, then fair enough, I won't argue -- it is your repository after all! Also, I will note that the PR was written a little while ago, so if I'm misremembering something and this change was needed then sorry! Either way, thanks for creating and maintaining this project.

@mark1foley
Copy link
Owner Author

@mark1foley mark1foley commented on 2860792 May 7, 2024 via email

Choose a reason for hiding this comment

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

Please sign in to comment.