question about FB login we used to use `getThirdPa...
# support-questions-legacy
i
question about FB login we used to use
getThirdPartyAuthorisationURLWithQueryParamsAndSetState
from
'supertokens-auth-react/recipe/thirdpartypasswordless'
but after upgrade to the latest package version we are getting in runtime the error:
Copy code
TypeError: Cannot read properties of undefined (reading 'startsWith')
    at appendQueryParamsToUR
I see in the docs this is the reference example:
import { getThirdPartyAuthorisationURLWithQueryParamsAndSetState } from "supertokens-web-js/recipe/thirdpartypasswordless";
is this the reason for the error or we are doing something else wrong?
r
hey @idanto which frontend SDK are you using?
i
react
r
which version?
i
supertokens-auth-react
latest 0.34.1
r
also, whats the version on supertokens-web-js in your package lock
i
0.7.2
backend returns 200 with status OK and url field in the response body
r
can i see how you are using this function?
the
getThirdPartyAuthorisationURLWithQueryParamsAndSetState
func
i
looks like a copy paste from the docs except the redirectUrl but I assume this can be whatever I want
r
and the error happens after the request is made?
i
you mean the network request?
r
yea
i
yea looks like
r
whats hte full error stack?
i
seems like the
getThirdPartyAuthorisationURLWithQueryParamsAndSetState
trigger the network request
and then it jumps to the catch
r
whats the response body from the API call?
i
Copy code
{
  "status": "OK",
  "url": "https://www.facebook.com/v9.0/dialog/oauth?scope=pages_show_list+pages_read_engagement+pages_read_user_content+pages_manage_posts+pages_manage_engagement+public_profile+email+instagram_basic+instagram_content_publish&response_type=code&client_id=1582699122221048"
}
looks legit, no?
r
it does.
@porcellus
which version of the backend SDk are you using?
i
old one but also tried with new one and same - but I will verify again
r
the old one will have this issue
the new one should not
so please try again with the new one
i
i'm in the middle of upgrade
r
the response body should have
urlWithQueryParams
instead of
url
i
ok let me verify
will just deploy the new verison
new version is using "supertokens-node": "^15.0.4"
deploying it now and give you results
r
sounds good. thans
i
the response from the BE looks the same in the new version as well
r
then it's not hitting the new version's API, or you don't actually have the new version
here is an example response from the new backend sdk version:
Copy code
{
  "status": "OK",
  "urlWithQueryParams": "https://supertokens.io/dev/oauth/redirect-to-provider?client_id=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fthirdpartypasswordless.demo.supertokens.com%2Fauth%2Fcallback%2Fgoogle&response_type=code&scope=openid+email&included_grant_scopes=true&access_type=offline&actual_redirect_uri=https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2%2Fv2%2Fauth"
}
i
pretty sure I do have it but let me double check
r
maybe enable backend debug logs and then call the API. The debug logs have the version in them
i
is this the right way to configure the backend? config: { thirdPartyId: 'facebook', clients: [ { clientId: configService.get('AUTH_FACEBOOK_CLIENT_ID'), additionalConfig: { clientSecret: configService.get( 'AUTH_FACEBOOK_CLIENT_SECRET', ), scope: [ 'pages_show_list', 'pages_read_engagement', 'pages_read_user_content', 'pages_manage_posts', 'pages_manage_engagement', 'public_profile', 'email', 'instagram_basic', 'instagram_content_publish', ], }, }, ], },
r
yes
i
inside ThirdPartyPasswordless.init and providers
r
correct
i
2023-08-14T16:13:09.265Z com.supertokens {t: "2023-08-14T16:13:09.265Z", message: "session init: cookieDomain: undefined", file: "/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:194:18" sdkVer: "15.0.4"} 41 40 39 2023-08-14T16:13:09.265Z com.supertokens {t: "2023-08-14T16:13:09.265Z", message: "session init: cookieSameSite: none", file: "/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:195:18" sdkVer: "15.0.4"} 38 37 2023-08-14T16:13:09.266Z com.supertokens {t: "2023-08-14T16:13:09.265Z", message: "session init: cookieSecure: true", file: "/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:196:18" sdkVer: "15.0.4"} 36 35 2023-08-14T16:13:09.266Z com.supertokens {t: "2023-08-14T16:13:09.266Z", message: "session init: refreshTokenPath: /authentication/auth/session/refresh", file: "/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:197:18" sdkVer: "15.0.4"} 34 2023-08-14T16:13:09.266Z com.supertokens {t: "2023-08-14T16:13:09.266Z", message: "session init: sessionExpiredStatusCode: 401", file: "/app/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:200:18" sdkVer: "15.0.4"} 33 32 [Nest] 7 - 08/14/2023, 4:13:09 PM LOG [InstanceLoader] HealthModule dependencies initialized +39ms 31 [Nest] 7 - 08/14/2023, 4:13:09 PM LOG [InstanceLoader] OpenTelemetryCoreModule dependencies initialized +1ms 30 [Nest] 7 - 08/14/2023, 4:13:09 PM LOG [InstanceLoader] AuthModule dependencies initialized +0ms 29 [Nest] 7 - 08/14/2023, 4:13:09 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms 28 {"level":30,"time":1692029589282,"pid":7,"hostname":"authentication-749c974b4d-fdfxk","context":"RoutesResolver","msg":"AppController {/}:"} 27 {"level":30,"time":1692029589283,"pid":7,"hostname":"authentication-749c974b4d-fdfxk","context":"RouterExplorer","msg":"Mapped {/, GET} route"} 26
r
what about when you call the API from getThirdPartyAuthorisationURLWithQueryParamsAndSetState?
i
trying now, just configured logs for the FE as well
now it suddenly works 🙂
r
so strange..
i
indeed
all I have changed is a value in the k8s config map to print the debug logs
r
maybe that caused it to invalidate some node cache?
not sure
i
it's a docker so I doubt there is a cache
and it has a always pullImagePolicy
r
you can switch off the debug logs and it should continue to work
im quite sure that it was somehow using the older version earlier
i
ok let's see 🙂
super strange but works
thanks for helping me debug
r
yup. Strange indeed. Sometimes node is.. strange
i
and at least we learn how easily we can turn on the logs
3 Views