Hi, I'm getting a 404 on `/auth/callback/github` w...
# support-questions
f
Hi, I'm getting a 404 on
/auth/callback/github
when trying to implement social login, but it works fine with email/password. Am I supposed to set up the backend callback myself ? I am using express (node) for the backend.
n
Hi, Can you follow this troubleshooting guide and post the output here? https://supertokens.com/docs/thirdparty/troubleshooting/how-to-troubleshoot
f
it looks something like this :
Copy code
[0] 2022-04-14T10:10:06.791Z com.supertokens {t: "2022-04-14T10:10:06.789Z", message: "middleware: Started", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}
[0] 
[0] 
[0] 
[0] 2022-04-14T10:10:06.798Z com.supertokens {t: "2022-04-14T10:10:06.794Z", message: "middleware: requestRID is: thirdpartyemailpassword", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
[0] 2022-04-14T10:10:06.800Z com.supertokens {t: "2022-04-14T10:10:06.799Z", message: "middleware: Checking recipe ID for match: thirdpartyemailpassword", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}
[0] 2022-04-14T10:10:06.802Z com.supertokens {t: "2022-04-14T10:10:06.800Z", message: "middleware: Matched with recipe ID: thirdpartyemailpassword", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}
[0] 
[0] 2022-04-14T10:10:06.814Z com.supertokens {t: "2022-04-14T10:10:06.812Z", message: "middleware: Request being handled by recipe. ID is: /authorisationurl", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
[0] 
[0] 2022-04-14T10:10:06.836Z com.supertokens {t: "2022-04-14T10:10:06.835Z", message: "Sending response to client with status code: 200", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}
[0] 
[0] 2022-04-14T10:10:06.860Z com.supertokens {t: "2022-04-14T10:10:06.859Z", message: "middleware: Ended", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}
[0]
Copy code
[0] GET /auth/authorisationurl?thirdPartyId=github 304 - - 71.685 ms
[0] 2022-04-14T10:10:08.147Z com.supertokens {t: "2022-04-14T10:10:08.146Z", message: "middleware: Started", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}
[0] 2022-04-14T10:10:08.150Z com.supertokens {t: "2022-04-14T10:10:08.149Z", message: "middleware: requestRID is: undefined", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
[0] 2022-04-14T10:10:08.151Z com.supertokens {t: "2022-04-14T10:10:08.151Z", message: "middleware: Checking recipe ID for match: thirdpartyemailpassword", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:220:34" sdkVer: "9.1.2"}
[0] 
[0] 
[0] 
[0] 2022-04-14T10:10:08.161Z com.supertokens {t: "2022-04-14T10:10:08.161Z", message: "middleware: Checking recipe ID for match: session", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:220:34" sdkVer: "9.1.2"}
[0] 
[0] 
[0] 2022-04-14T10:10:08.164Z com.supertokens {t: "2022-04-14T10:10:08.163Z", message: "middleware: Not handling because no recipe matched", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:243:30" sdkVer: "9.1.2"}
[0] GET /auth/callback/github?code=xxxxxxxxxx 404 159 - 26.428 ms*
n
When your server starts it should print out some logs, please send the output of that. Also send the config you are using when calling SuperTokens.init on the frontend (stripping any API keys you may have used)
f
Copy code
[0] 2022-04-14T10:09:42.305Z com.supertokens {t: "2022-04-14T10:09:42.305Z", message: "appInfo: {"appName":"ModpackCreator","apiDomain":"http://localhost:3000","websiteDomain":"http://localhost:4000","apiBasePath":"/auth","websiteBasePath":"/auth"}", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:271:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.306Z com.supertokens {t: "2022-04-14T10:09:42.306Z", message: "framework: express", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/supertokens.js:273:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.331Z com.supertokens {t: "2022-04-14T10:09:42.331Z", message: "session init: antiCsrf: NONE", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:164:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.333Z com.supertokens {t: "2022-04-14T10:09:42.332Z", message: "session init: cookieDomain: undefined", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:165:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.334Z com.supertokens {t: "2022-04-14T10:09:42.333Z", message: "session init: cookieSameSite: lax", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:166:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.336Z com.supertokens {t: "2022-04-14T10:09:42.335Z", message: "session init: cookieSecure: false", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:167:18" sdkVer: "9.1.2"}
[0] 2022-04-14T10:09:42.339Z com.supertokens {t: "2022-04-14T10:09:42.337Z", message: "session init: refreshTokenPath: /auth/session/refresh", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:168:18" sdkVer: "9.1.2"}
Copy code
[0] 2022-04-14T10:09:42.341Z com.supertokens {t: "2022-04-14T10:09:42.341Z", message: "session init: sessionExpiredStatusCode: 401", file: "/home/firokat/ModpackCreator/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:171:18" sdkVer: "9.1.2"}
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: "http://localhost:3567",
        // 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: "ModpackCreator",
        apiDomain: "http://localhost:3000",
        websiteDomain: "http://localhost:4000",
        apiBasePath: "/auth",
        websiteBasePath: "/auth"
    },
    recipeList: [
        ThirdPartyEmailPassword.init({
          providers:[
            Github({
              clientId: "xxxxxxxxx",
              clientSecret: "xxxxxxxxxxxxxxxxxxx"
            })
          ]
        }),
        Session.init() // initializes session features
    ]
});
n
I meant the config for your Frontend application
f
Copy code
js
SuperTokens.init({
    apiDomain: "http://localhost:3000",
    apiBasePath: "/auth"
});
just the one from the doc
n
What frontend sdk are you using?
f
plain JS (i use svelte)
n
So it seems that Github is trying to redirect to
localhost:3000/auth/callback/github
which is incorrect, it should be redirecting to
localhost:4000
can you double check your configuration on Github?
f
it redirects to
http://localhost:4000/auth/callback/github
n
GET /auth/callback/github?code=xxxxxxxxxx 404 159 - 26.428 ms*
This indicates that your backend server received a request for that route, are you trying to call the signinup API?
f
i just fixed the port number for the redirect_uri but it doesn't seem to work, here is my function handling the login, I used this : https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokens, but I'm not sure my function is correct
Copy code
js
async signInWithGithub(){
        return new Promise((ok,err)=>{
            axios.get('/auth/authorisationurl?thirdPartyId=github',{headers:{"rid":"thirdpartyemailpassword"}})
                .then(res=>{
                    let data = res.data
                    if (data.status=="OK"){
                        let url = new URL(data.url)
                        url.searchParams.append("redirect_uri", "http://localhost:4000/auth/callback/github")
                        //url = url.toString()
                        window.open(url, '_blank')
                        
                    }
                })
        })
    }
n
So after that function is called and you open Github, does it get redirected back to
http://localhost:4000/auth/callback/github
after the Github auth flow has completed?
f
it does
n
And on that page what logic do you have?
f
i have nothing setup on my frontend for that
i guess i shoud handle it like shown in "Step 2" ?
n
Right so the plain js SDK does not handle any routes for you, after you are redirected to
http://localhost:4000/auth/callback/github
you need to call the
/signinup
API manually. You can refer to https://supertokens.com/docs/fdi to know what the API expects
yes
f
i'll look into it later in the day, thanks for your halp anyway
n
Happy to help
5 Views