fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Oauth2 in Fresh?

Open wongataa opened this issue 2 years ago • 4 comments

Hey, I'm new to Deno and Fresh, but was hoping to get my feet wet with an oauth application. I found several frameworks that work with Oak[1][2], but none with Fresh. I saw Fresh has removed its Oak dependencies and I can't see how I would use either framework. Is there another option?

Thanks for your work with Fresh; it looks great

[1] https://bedrockauth.dev/docs.html [2] https://github.com/oslabs-beta/dashport

wongataa avatar Sep 01 '22 23:09 wongataa

I'd probably recommend using something like the third party oauth2 module. It's a more annoying to set up than a more opinionated setup but it will theoretically work for whatever you're trying to do.

https://deno.land/x/oauth2

It would be cool to see a first-party/opinionated offering from fresh though.

lino-levan avatar Sep 02 '22 00:09 lino-levan

I use a strapi backend, so I have setup my OAuth there pasting keys in.

Then my fresh sites can use that API for OAuth. Here's a basic example:

The initial redirect to start the login process: https://github.com/Hyprtxt/fresh-strapi.deno.dev/blob/main/routes/login/%5Bprovider%5D.js

The callback route: https://github.com/Hyprtxt/fresh-strapi.deno.dev/blob/main/routes/api/%5Bprovider%5D/auth.js

Here's a working example: https://fresh-strapi.deno.dev/login It's just currently using another projects config, so the consent screen is wrong (videopoker.academy).

The backend is completely proxied away from the users this way. It's not OAuth done 'in deno" as strapi is node and uses grant. But it is effective for me.

digitaldesigndj avatar Sep 03 '22 17:09 digitaldesigndj

thanks to you both for your quick comments and pointers. I'll check both options out and run with one.

@digitaldesigndj cheers for the extensive details you've included too

wongataa avatar Sep 03 '22 18:09 wongataa

Check this library https://github.com/w3cj/deno_grant/

omar2205 avatar Sep 10 '22 11:09 omar2205

Using official deno kv https://github.com/denoland/deno_kv_oauth

maintenance by deno team

afifurrohman-id avatar Jul 25 '23 16:07 afifurrohman-id

This should also be closed now that we have documentation for using deno_kv_oauth as well: https://fresh.deno.dev/docs/examples/using-deno-kv-oauth.

deer avatar Aug 06 '23 08:08 deer