localhost
→ 127.0.0.1
will work. IIRC, this was specifically done for JOSM. But you might be interested in Allow HTTP to localhost on list of redirect URIs for OAuth2 applications · Issue #3613 · openstreetmap/openstreetmap-website · GitHub .
- JOSM (done by me) – Java
- Vespucci (done by SimonPoole) – Java
- StreetComplete (done by westnordost , IIRC) – Kotlin (could have used Java)
- GoMap! (done by bryceco) – Swift IIRC
- ??? (I can almost guarantee that some other editor has written their own OAuth 2 implementation)
To be fair to JOSM and Vespucci, I believe we wrote our OAuth2 implementations concurrently. I should have reached out to @SimonPoole to avoid duplication of work.
Quite frankly, the OAuth 2 authentication dance is simple. If someone cannot write a client for it given the specification, I strongly question whether or not they should be trying to write data to a live database using software they have written. Even with that caveat, most people should use a library for OAuth2. OSM even has an RFC 8414 compliant endpoint, so some libraries won’t even require configuration beyond the client id and the domain.
I assume you are talking about client credentials. The specification specifically says
The client credentials grant type MUST only be used by confidential clients.
This is not the case with any client-side application. All client side applications are not “confidential” clients. You could probably make an argument if the user has to provide their own client id and client secret though.
With that said, I would highly recommend all new OAuth 2 clients implement the extensions that are required as part of the draft OAuth 2.1 specification and treat the OSM authentication endpoints as if the were OAuth 2.1 compliant. Of note, one of the things that the draft specification removes is the implicit
grant type; it was removed because it could be intercepted by a malicious application.
If, for whatever reason, you don’t feel like having your application listen to a port on localhost, (127.0.0.1
), you can have the user copy/paste the redirect URL and perform the rest of the authentication dance in the application. Which is “just” network requests, but if you are talking with the OSM API, you already are making network requests.