https://supertokens.com/ logo
twitter login
a

Alen

02/06/2023, 10:42 AM
Hi, how can I add Twitter as a customProvider in ThirdPartyPasswordless Authentication method? And is Twitter supported via supertokens?
r

rp

02/06/2023, 11:06 AM
hey @Alen twitter doens't use oauth 2.0. So we don't support it.
a

Alen

02/06/2023, 11:08 AM
I read this from their docs page. Here they have OAuth 2.0 methods. Isn't it supported ?
r

rp

02/06/2023, 11:17 AM
well.. they don't give access to oauth 2. You need to apply to them and stuff
but if you get access to their oauth 2.0, then you can add them as a custom provider with supertokens
a

Alen

02/06/2023, 11:30 AM
@rp We got the access, Im trying to add it as custom provider, but facing some issues.
r

rp

02/06/2023, 11:41 AM
whats the issue? And can i see the custom provider's code>?
a

Alen

02/06/2023, 11:42 AM
I'm getting little confused of what Endpoint to be used and what all values should I pass.
r

rp

02/06/2023, 11:42 AM
can you share the config?
a

Alen

02/06/2023, 11:43 AM
{
                    id: "twitter",
                    get: (redirectURI, authCodeFromRequest) => {
                        return {
                            accessTokenAPI: {
                                url: "https://api.twitter.com/oauth/authorize",
                                params: {
                                    client_id: "XXX",
                                    client_secret: "XXX",
                                    grant_type: "client_credentials",
                                    redirect_uri: redirectURI || "",
                                    code: authCodeFromRequest || "",
                                }
                            },
                            authorisationRedirect: {
                                url: "https://api.twitter.com/oauth/authorize",
                                params: {
                                    client_id: "XXX",
                                    scope: "users.read",
                                    response_type: "code",
                                }
                            },
                            getClientId: () => {
                                return "Zk9UcENQWXkyWlJTQ3RvbmJrSno6MTpjaQ";
                            },
                            getProfileInfo: async (accessTokenAPIResponse) => {
                                return {
                                        id: string, // user ID as provided by the third party provider
                                        email: { 
                                            id: string, // emailID
                                            isVerified: boolean // true if the email is verified already
                                        },
                                        token: accessTokenAPIResponse
                                };
                            }
                        }
                    }
                }
r

rp

02/06/2023, 11:43 AM
when you click on login with twitter, do you get redirected to twitter's login page?
a

Alen

02/06/2023, 11:44 AM
yeah its getting redirected, but the endpoints are not working properly, getting error on their page
r

rp

02/06/2023, 11:44 AM
right. whats the error? can i see a screenshot?
a

Alen

02/06/2023, 11:45 AM
First of all , when I give id as twitter it throws error.
but when I give custom it doesnt
This is error which I get
r

rp

02/06/2023, 11:47 AM
what ID have you configured on the frontend?
a

Alen

02/06/2023, 11:47 AM
I tried giving "twitter" both frontend and backend, it didnt work. but giving custom did work
So currently its just custom
r

rp

02/06/2023, 11:48 AM
custom should not work cause the backend has twitter on the backend
a

Alen

02/06/2023, 11:49 AM
No I changed it to custom in backend too
r

rp

02/06/2023, 11:50 AM
right
let me check
a

Alen

02/06/2023, 11:50 AM
Sure
r

rp

02/06/2023, 11:50 AM
yea.. im not sure why using the id twitter won't work
can you use the it "twitter2" and see if that works?
a

Alen

02/06/2023, 11:51 AM
I think its working now.
r

rp

02/06/2023, 11:51 AM
hmm
a

Alen

02/06/2023, 11:52 AM
I just tried abc and then again gave twitter, so its working
r

rp

02/06/2023, 11:52 AM
weird..
a

Alen

02/06/2023, 11:53 AM
Not able to figure how to resolve the endpoint issue and what all values should I pass.
r

rp

02/06/2023, 11:57 AM
whats the error you are getting now?
a

Alen

02/06/2023, 11:57 AM
this one
r

rp

02/06/2023, 11:58 AM
right. I think request token is for oauth 1.0
a

Alen

02/06/2023, 11:59 AM
yeah its expecting a post call with bearer token to fetch the token.
r

rp

02/06/2023, 12:00 PM
thats oauth 1.0. Which we don't support
a

Alen

02/06/2023, 12:01 PM
I see only this one , and this is what I have used.
r

rp

02/06/2023, 12:01 PM
im not too sure at the moment.
When we add twitter, we can get back to you
a

Alen

02/06/2023, 12:02 PM
But this is for authorize right, but the accessTokenAPI method you have given, Im not sure what endpoint should I provide.
Sure, thanks a lot. I will also play around.
Hey @rp , any timeline when you guys can implement twitter as a thirdParty social Oauth2.0?
r

rp

02/15/2023, 8:33 AM
no timeline set for this yet @Alen
but it still seems that twitter does not properly support oauth 2.0. But im not sure
a

Alen

02/15/2023, 9:06 AM
Sure let me know if you guys integrate it anytime soon.
j

Janus Reith

03/23/2023, 1:25 PM
Hi @rp, looking at their docs it looks like Twitter supports OAuth 2.0 now, likewise next-auth seems to support that optionally now: https://next-auth.js.org/providers/twitter#oauth-20 I just started investigating SuperTokens, is adding a custom OAuth 2.0 Twitter Provider feasible in case this is not something your team is going to release any time soon? Thanks!
r

rp

03/23/2023, 1:26 PM
yea, we have a section in our docs for adding custom providers. Using twitter's oauth 2.0 should be easily do-able via this
j

Janus Reith

03/23/2023, 1:29 PM
Awesome, thank you for the super fast response!
BTW: Happy if anyone reading this already did add twitter and could share their experience 🙂