Open ReneNyffenegger opened 1 month ago
The script should expect that code after the "Enter the authorization code:" prompt, as seen here. Does it for you?
When I run the script, it now prints the line
Please visit this URL to authorize this application: https://www.openstreetmap.org/oauth2/authorize?response_type=code&client_id=...redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2F&scope=read_prefs+write_prefs+write_dia...
and opens the indicated URL in the browser.
The URL displays
The requested redirect uri is malformed or doesn't match client redirect URI.
When I then close the browser, the script seems to be stuck so that I have to terminated it with ctrl-c
.
When I ran the script for the first time, the URL gave me an authorization code but I still had to quit the script with ctrl-c
.
@ReneNyffenegger I made the same mistake. The part that stands out to me:
Please visit this URL to authorize this application: https://www.openstreetmap.org/ ...
&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2F&
The problem is the README example is using auth_server()
which is documented to start a localhost http server, while following the OpenStreetMap "easiest possible OAuth fix" you probably did the same as I did and created the OAuth app using urn:ietf:wg:oauth:2.0:oob
?
It's an easy fix!
-auth = OpenStreetMapAuth(...).auth_server(token_test=lambda r: r.get('user/details'))
+auth = OpenStreetMapAuth(...).auth_code()
I made a successful API call! Woo!
Rene, the redirect uri is http://localhost:8080/
. Does it match the one you entered into the application redirect list? It should, otherwise you'll get the error you pasted.
auth_code()
bypasses double-checking the redirect, but it's harder for users.
I am running the usage script as specified in the
README.md
file and am then asked to open a url that starts withPlease visit this URL to authorize this application: https://www.openstreetmap.org/oauth2/authorize?response_type=code&client_id
.When I follow this URL, an authorization code is created for me.
I have no idea what I need to do with it or how I am supposed to proceed.