pvharmo
04/13/2022, 2:03 PM{message: "middleware: requestRID is: thirdpartyemailpassword", file: "node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
{message: "middleware: Checking recipe ID for match: thirdpartyemailpassword", file: "node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}
{message: "middleware: Matched with recipe ID: thirdpartyemailpassword", file: "node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}
{message: "middleware: Request being handled by recipe. ID is: /signinup", file: "node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
{message: "middleware: Started", file: "node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}
{message: "middleware: requestRID is: anti-csrf", file: "node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
{message: "middleware: Checking recipe ID for match: thirdpartyemailpassword", file: "node_modules/supertokens-node/lib/build/supertokens.js:220:34" sdkVer: "9.1.2"}
{message: "middleware: Request being handled by recipe. ID is: /authorisationurl", file: "node_modules/supertokens-node/lib/build/supertokens.js:225:38" sdkVer: "9.1.2"}
{message: "Sending response to client with status code: 200", file: "node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}
response : { status: 'FIELD_ERROR', error: 'Request failed with status code 401' }
nkshah2
04/13/2022, 2:07 PMpvharmo
04/13/2022, 2:07 PMpvharmo
04/13/2022, 2:10 PMRequest failed with status code 401
means that it is Supertokens that sent a 401 or is it Google?rp_st
04/13/2022, 2:18 PMrp_st
04/13/2022, 2:18 PMpvharmo
04/13/2022, 2:21 PMrp_st
04/13/2022, 2:22 PMpvharmo
04/13/2022, 2:24 PMpvharmo
04/13/2022, 2:26 PMrp_st
04/13/2022, 2:30 PMoriginalImplementation.thirdPartySignInUpPOST(input)
and print out the error objectpvharmo
04/13/2022, 2:37 PMlet response
try {
response = await originalImplementation.thirdPartySignInUpPOST(input)
} catch(e) {console.log(e)}
console.log(response)
All that is logged is { status: 'FIELD_ERROR', error: 'Request failed with status code 401' }
from console.log(response)
rp_st
04/13/2022, 2:38 PMrp_st
04/13/2022, 2:42 PMproviders
array, do this:rp_st
04/13/2022, 2:43 PMjs
let google = ThirdPartyEmailPassword.Google({
clientId: "",
clientSecret: "",
});
ThirdPartyEmailPassword.init({
providers: [
{
...google,
get: function (redirectURI: string | undefined, authCodeFromRequest: string | undefined, userContext: any) {
let getResult = google.get(redirectURI, authCodeFromRequest, userContext);
return {
...getResult,
getProfileInfo: async function (authCodeResponse: any, userContext: any) {
try {
return getResult.getProfileInfo(authCodeResponse, userContext);
} catch (err) {
console.log(err);
throw err;
}
}
}
}
},
],
});
rp_st
04/13/2022, 2:44 PMclientId
and clientSecret
rp_st
04/13/2022, 2:44 PMrp_st
04/13/2022, 2:45 PMpvharmo
04/13/2022, 3:07 PMhttps://www.googleapis.com/auth/userinfo.email
. It is probably because I set other scopes in ThirdPartyEmailPassword.Google
and so, it didn't take the default scopes from the SDKrp_st
04/13/2022, 3:16 PMpvharmo
04/13/2022, 4:21 PMError: Request failed with status code 401
at createError (/home/jonathan/Documents/thinkdrive/auth/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/jonathan/Documents/thinkdrive/auth/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/jonathan/Documents/thinkdrive/auth/node_modules/axios/lib/adapters/http.js:269:11)
It also printed the config for axios request and response.
config: {
url: 'https://www.googleapis.com/oauth2/v1/userinfo',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
Authorization: 'Bearer ya29.A0ARrdaM86A9IMFJKHehpYCx372RggXa8Pf7hakMe7SA9vuKRG-4aUO_cz-OmdFyUV1tIPliEXf3AeRkzCGQKpok0L8GMTIgMePClv1C88BFrtf7WZZt2669P-fI46935M6Hq0kDtjWMDWjPJB-y1kz6aGDCyh',
'User-Agent': 'axios/0.21.4'
},
...
It's like you said though, there wasn't much more information in the error, but knowing the url for the request which caused the error helped a lot.rp_st
04/13/2022, 4:21 PMpvharmo
04/13/2022, 4:23 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by