lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
9.24k stars 469 forks source link

[Feature Request]: Twitter OAuth1 Provider #289

Closed JohnRSim closed 1 year ago

JohnRSim commented 1 year ago

Package

lucia-auth

Describe the problem

Previously I was using SvelteKit Auth

The issue is - "OAuth 2.0 can only be used with the Twitter API v2."

The problem with this is that the twitter v2 API's still only has limited support for all the features

Some examples of limitations with v2 that you can only do with v1 -

media upload user email retrieval activity api bookmark api

Describe the proposed solution

It would be great to be able to use Lucia-auth with a built in Twitter provider.

Alternatives considered

Looking at SK-Auth SK-Auth

or

Supabase https://supabase.com/docs/guides/auth/auth-helpers/sveltekit https://github.com/supabase/auth-helpers/tree/main/packages/sveltekit

Additional information

Unfortunately with Supabase and the twitter provider - you cannot get access to secret token returned by Twitter.

No response

pilcrowOnPaper commented 1 year ago

Ok 2 things:

  1. OAuth 1 seems to be such a pain to do
  2. I thought about doing it right now but since I don't have experience working with v1, I'll hold this off until I have enough time on my hand
JohnRSim commented 1 year ago

I understand ;) - Keep up the great work! Just setup your sveltekit example and playing with it now with github / Prisma ;)

I'll take a look at using SK-Auth approach using this twitter-api-v2 package https://github.com/plhery/node-twitter-api-v2/blob/HEAD/doc/auth.md and tie it in with lucia createUser as a tmp quick solution :)

JohnRSim commented 1 year ago

@pilcrowOnPaper Created a very, very rough gist example using twitter-api-v2 with sveltekit to handle the OAuth1. https://gist.github.com/JohnRSim/db5c8378707e8ab7011a956ffeab1115

Let me know if you see any issue with this - thanks :)

pilcrowOnPaper commented 1 year ago

Does cookies.delete() work? I've heard you need to specify the route, Other than that, looks good to me.

JohnRSim commented 1 year ago

Yup cookies.delete works I had to change the cookies path on set from / to active path. It's deleting fine when I check chrome console.

Great - so far everything's working smoothly the only thing that caught me out as I'm new the prisma is when updating the schema having to run push db otherwise I get errors in prisma studio.

pilcrowOnPaper commented 1 year ago

Ok I tried to do this again, but it was such a pain in the ass to do and gave up. I did make sure it was possible to add this without a breaking change so I'll tackle this post-1.0.

cusxio commented 1 year ago

What about Twitter OAuth 2.0 would that be more straight forward?

pilcrowOnPaper commented 1 year ago

OAuth 2.0 (likely) would be much easier

cusxio commented 1 year ago

Do you think it make sense to have two providers then? One for 1.0 and one for 2.0.

I ask this cause I'm eager to try lucia out. I can technically write my own Twitter provider, but it seems that the most of the utils needed to write a provider are not exported?

Torbet commented 1 year ago

Any update here on using Twitter OAuth 2?

pilcrowOnPaper commented 1 year ago

This may be unpopular, but I've decided to not implement Twitter OAuth 1.0a. It's an archaic spec that has been deprecated over 10 years ago. I do not think it's worth the effort to add and maintain an OAuth 1.0a implementation, especially to support just one (admittedly large) provider. We are not supporting CJS for the same reasons.

That said, I'm planning to add Twitter OAuth 2.0 with PKCE.