Hello! when i click login on the sign in / sign up...
# support-questions
i
Hello! when i click login on the sign in / sign up screen (with a discord config, thanks not the problem: it works) in the console of the browser it gets a 404 to
http://localhost:8080/auth/authorisationurl?thirdPartyId=discord
though, it just works when i go there manually. why is that and is there a fix?
n
Hello! when i click login on the sign in / sign up screen (with a discord config, thanks not the problem: it works) in the console of the browser it gets a 404 to
http://localhost:8080/auth/authorisationurl?thirdPartyId=discord
though, it just works when i go there manually. why is that and is there a fix?
Hey @User can you post the appInfo you use when calling
SuperTokens.init
on the frontend?
Also for the backend
i
Yea sure, no problem: this is the backend
Copy code
js
supertokens.init({    
    framework: "express",    
    supertokens: {        
        // try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.        
        connectionURI: "https://try.supertokens.com",        // apiKey: "IF YOU HAVE AN API KEY FOR THE CORE, ADD IT HERE",    
    },    appInfo: {        // learn more about this on https://supertokens.com/docs/thirdpartyemailpassword/appinfo        
        appName: "Exalt Panel",        
        apiDomain: "http://localhost:8080",        
        websiteDomain: "http://localhost:3000",        
        apiBasePath: "/auth",        
        websiteBasePath: '/'    
    },    recipeList: [        
        ThirdPartyEmailPassword.init({
            providers: [
                Discord({
                    clientId: '<ID>',
                    clientSecret: '<secret>',
                    scope: [
                        'identify',
                        'guilds'
                    ]
                })
            ]
        }),        
        Session.init() // initializes session features    
    ]});
and this is the frontend:
Copy code
js
SuperTokens.init({    
    appInfo: {        
        appName: "Exalt Panel",        
        apiDomain: "http://localhost:8080",        
        websiteDomain: "http://localhost",        
        apiBasePath: "/auth",        
        websiteBasePath: "/"    
    },    recipeList: [        
        ThirdParty.init({            
            signInAndUpFeature: {  
                getRedirectionURL: async (context) => {                
                    if (context.action === "SUCCESS") {                    
                        if (context.redirectToPath !== undefined) {                        
                            // we are navigating back to where the user was before they authenticated                        
                            return context.redirectToPath;                    
                        }                    
                        return "/panel";                
                    }                
                    return undefined;            
                },              
                providers: [                    
                    {                        
                        id: "discord",                        
                        name: "Discord" // Will display "Continue with X"                    
                    }
                ]            
            }        
        }),        
        Session.init()    
    ]});
r
On the frontend, you want to set websiteDomain to
http://localhost:3000
as well.
i
I have done that since, but that doesn't solve the 404
r
Also, in the backend, you use
ThirdPartyEmailPassword
but in the frontend, you are using
ThirdParty
. You want to initialise the same recipe on both frontend and backend
i
Oh yea, that solved it, thanks! But, the backend wants a field named: "id", but it is not sent to the /auth/signinup endpoint. here's the error and request:
SuperTokens core threw an error for a POST request to path: '/recipe/signinup' with status code: 400 and message: Field name 'id' is invalid in JSON input
and the request:
Copy code
{"code":
<codeHere>","thirdPartyId":"discord","redirectURI":"http://localhost:3000/callback/discord","clientId":"discord"}
r
hmm. That's odd
Can you edit the supertokens-node SDK in node_modules to add a
console.log(userIfo)
at this location: https://github.com/supertokens/supertokens-node/blob/master/lib/build/recipe/thirdparty/providers/discord.js#L75
The flow works for me.
i
It appears that it doesnt reach that, it errors here:
Copy code
at Querier.<anonymous> (D:\react-dev\exalt-web\exalt-frontend-backend\backend\node_modules\supertokens-node\lib\build\querier.js:252:31)
    at Generator.throw (<anonymous>)
    at rejected (D:\react-dev\exalt-web\exalt-frontend-backend\backend\node_modules\supertokens-node\lib\build\querier.js:22:44)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
r
Can we get on a quick call to debug?
i
I'd be more then happy to do that, but i'm in school right now 😛
r
haha ok. Then well...
what versions of the SDKs are you using?
i
I'd be available in about 3 hours, are you available hen aswell?
Most recent one, just added the packages today
r
> I'd be available in about 3 hours, are you available hen aswell? Sure. You can book a call with me as per your time preference: https://supertokens.com/call-user
i
wow thats pretty cool
Does it cost money though?
r
to book a call? No..
this isn't so much of a consultation as it is more a debugging thing. It helps us to know how to further improve the lib / docs.
Cause it seems the configs are right... but it's still not working. Which is really strange. And even more so cause it works well for me
i
I booked a call, should be 5 GMT
r
sounds good! talk to you then
i
it sent me a zoom link, can we call via discord though
r
Discord calls behave weirdly for me.. we can try it out though.
i
@User so on my home PC it does reach the console.log(userinfo). this is what it spits out:
Copy code
json
{
  id: '576624954997604353',
  username: 'IKEW',
  flags: 128,
  banner: null,
  banner_color: null,
  accent_color: null,
  locale: 'en-US',
  mfa_enabled: true
}
r
Right. So that seems right. Does the whole flow work for you?
oh hmm.. it won't cause email is missing
we need the email ID of the user for them to be able to login via discord
otherwise it will reject the login attempt - is this what you are seeing?
i
This is visually what i'm seeing:
r
Can I see the network response output?
From the browser network tab
i
Yea sure:
r
i see.
i
Yes so
This was the problem
r
is there any stack trace produced on the backend. cause it shouldn't give a 500 error
i
i added "email" as scope and now there's no errors!
r
ahh right
we add the email scope by default anyway
i
oh
r
unless you give a scopes array yourself
i
well i added it manually and now it seems to work
r
which you have
i
Yea
r
ok cool!
i
Yea, thanks man!
r
shall I cancel our call?
i
Yes please
186 Views