Discord OAuth #120
-
I'm developing a WPF application, trying to do authorization via Discord. How can I open a window in the browser for authorization? If this is not possible, then how can I implement authorization via Discord in another way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Here's the answer... but it's non-trivial to implement. Option A: You'll want to open up the user's browser with the correct Discord URL. That will kick it over to the Supabase project URL under the covers to handle getting a session. Then you'll want the Supabase project to kick it back to your app using a deep link. Deep linking varies pretty dramatically. Option B: When the user starts the Discord log in process, also open a connection back to your server (e.g. via WebSockets or polling an endpoint). This will listen for a login with a unique id generated by the app. Then open the browser flow for the Discord login, which concludes with the login hitting a web page you set up. This web page then posts the login code back to the unique id you initially set up for the app login. The app gets this code from the websocket listener/polling and uses that to complete the session. Option A requires setting up deep links for your app, which is pretty OS specific. Option B is a nicer flow IMHO but means you need a web app (I suggest SvelteKit + Vercel but that's just one of countless options). FWIW I found that just having a web app to handle a lot of these user identity functions (eg. password reset, email verification) was easier than trying to do it with deep links, but of course YMMV. Either way implementing Discord (or any other OAuth flow) in a desktop app is going to require some time & patience... |
Beta Was this translation helpful? Give feedback.
Here's the answer... but it's non-trivial to implement.
Option A: You'll want to open up the user's browser with the correct Discord URL. That will kick it over to the Supabase project URL under the covers to handle getting a session. Then you'll want the Supabase project to kick it back to your app using a deep link. Deep linking varies pretty dramatically.
Option B: When the user starts the Discord log in process, also open a connection back to your server (e.g. via WebSockets or polling an endpoint). This will listen for a login with a unique id generated by the app. Then open the browser flow for the Discord login, which concludes with the login hitting a web page you set up. This web…