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

broken auth on payloads containing tilde chars #72

Closed
shahin opened this issue Apr 6, 2015 · 1 comment
Closed

broken auth on payloads containing tilde chars #72

shahin opened this issue Apr 6, 2015 · 1 comment
Assignees

Comments

@shahin
Copy link

shahin commented Apr 6, 2015

client.py uses urllib.urlencode, which percent-encodes the tilde character (~) as %7E in order to generate the signature. ~ isn't really a reserved character, so this isn't guaranteed consistent with other URI libraries.

On the other hand, the base_url is encoded via requests in which the tilde issue has been corrected and no longer matches urllib's weird behavior.

Ultimately this results in a 403 error (client id omitted below):

"Unable to authenticate the request. Provided 'signature' is not valid for the provided client ID, or the provided 'client' is not valid.
The signature was checked against the URL: /maps/api/geocode/json?address=560+Maple+Street+South+%2310~&components=administrative_area%3AMN%7Clocality%3AWaconia%7Cpostal_code%3A55387&client=
If this does not match the URL you requested, please ensure that your request is URL encoded correctly. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth"

Although tildes should be rare, ideal behavior would probably be either:

  1. Use the same encoding library for the base_url and for computing the authed_url, or
  2. Raise an informative exception on disallowed characters (incl. tilde)

instead of waiting for a non-specific 403.

@stephenmcd stephenmcd self-assigned this Apr 21, 2015
stephenmcd added a commit to stephenmcd/google-maps-services-python that referenced this issue Apr 22, 2015
@stephenmcd
Copy link
Contributor

Thanks a lot for the detailed report! I've a fix incoming.

markmcd added a commit that referenced this issue Apr 22, 2015
Don't urlencode unreserved chars. Closes #72.
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

No branches or pull requests

2 participants