[OSM-dev] OAuth2 in C#

Tom Hughes tom at compton.nu
Tue Jun 7 15:37:42 UTC 2022


The best documentation is probably the examples in the test code:

https://github.com/openstreetmap/openstreetmap-website/blob/master/test/integration/oauth2_test.rb

The second test there is OOB though it doesn't use PKCE but you
could mix in the PKCE stuff from the following cases - you just
need to generate the verifier and pass it when asking for the
initial authorization and again when asking for the token.

Tom

On 07/06/2022 16:13, Michele OSM3 wrote:
> Many thanks for answer.
> Yes, I am attempting to use the OSM API and am trying to log in via OAuth2.
> I registered my application in 
> https://master.apis.dev.openstreetmap.org/user/[user]/oauth_clients 
> <https://master.apis.dev.openstreetmap.org/user/[user]/oauth_clients> 
> using a the redirect urn:ietf:wg:oauth:2.0:oob for non-web application 
> as described on: https://wiki.openstreetmap.org/wiki/OAuth#OAuth_2.0 
> <https://wiki.openstreetmap.org/wiki/OAuth#OAuth_2.0>.
> 
> Now I'm trying to figure out how to get the authorization code.
> In the case of a non-web application, do I have to generate the 
> authorization code myself and then pass it through PKCE?
> 
> 
> 
> 
> 
> 
> 
> Il giorno mar 7 giu 2022 alle ore 16:23 Tom Hughes <tom at compton.nu 
> <mailto:tom at compton.nu>> ha scritto:
> 
>     On 07/06/2022 14:22, Michele OSM3 wrote:
>      > Can anyone help me on OAuth2 in C#?
>      > I tried this example, but it doesn't work:
>      >
>     https://stackoverflow.com/questions/32923325/obtain-bearer-token-using-httpclient
>     <https://stackoverflow.com/questions/32923325/obtain-bearer-token-using-httpclient>
> 
>      >
>     <https://stackoverflow.com/questions/32923325/obtain-bearer-token-using-httpclient
>     <https://stackoverflow.com/questions/32923325/obtain-bearer-token-using-httpclient>>
>     If you mean for OSM then we don't support the client credentials
>     flow which that is using.
> 
>     You need to use the authorization code flow, ideally with PKCE.
> 
>     Tom
> 
>     -- 
>     Tom Hughes (tom at compton.nu <mailto:tom at compton.nu>)
>     http://compton.nu/ <http://compton.nu/>
> 


-- 
Tom Hughes (tom at compton.nu)
http://compton.nu/



More information about the dev mailing list