Hi, how can I add Twitter as a customProvider in T...
# support-questions-legacy
a
Hi, how can I add Twitter as a customProvider in ThirdPartyPasswordless Authentication method? And is Twitter supported via supertokens?
r
hey @alen_george twitter doens't use oauth 2.0. So we don't support it.
a
I read this from their docs page. Here they have OAuth 2.0 methods. Isn't it supported ?
r
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
@rp_st We got the access, Im trying to add it as custom provider, but facing some issues.
r
whats the issue? And can i see the custom provider's code>?
a
I'm getting little confused of what Endpoint to be used and what all values should I pass.
r
can you share the config?
a
Copy code
{
                    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
when you click on login with twitter, do you get redirected to twitter's login page?
a
yeah its getting redirected, but the endpoints are not working properly, getting error on their page
r
right. whats the error? can i see a screenshot?
a
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
what ID have you configured on the frontend?
a
I tried giving "twitter" both frontend and backend, it didnt work. but giving custom did work
So currently its just custom
r
custom should not work cause the backend has twitter on the backend
a
No I changed it to custom in backend too
r
right
let me check
a
Sure
r
yea.. im not sure why using the id twitter won't work
can you use the it "twitter2" and see if that works?
a
I think its working now.
r
hmm
a
I just tried abc and then again gave twitter, so its working
r
weird..
a
Not able to figure how to resolve the endpoint issue and what all values should I pass.
r
whats the error you are getting now?
a
this one
r
right. I think request token is for oauth 1.0
a
yeah its expecting a post call with bearer token to fetch the token.
r
thats oauth 1.0. Which we don't support
a
I see only this one , and this is what I have used.
r
im not too sure at the moment.
When we add twitter, we can get back to you
a
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_st , any timeline when you guys can implement twitter as a thirdParty social Oauth2.0?
r
no timeline set for this yet @alen_george
but it still seems that twitter does not properly support oauth 2.0. But im not sure
a
Sure let me know if you guys integrate it anytime soon.
j
Hi @rp_st, 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
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
Awesome, thank you for the super fast response!
BTW: Happy if anyone reading this already did add twitter and could share their experience 🙂