ERROR [ExceptionsHandler] Received response with s...
# support-questions-legacy
n
ERROR [ExceptionsHandler] Received response with status 401 and body
this error seems to be unhandled:
Copy code
bash
[Nest] 49152  - 01/03/2024, 11:30:23 PM   ERROR [ExceptionsHandler] Received response with status 401 and body {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
Error: Received response with status 401 and body {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
    at Object.exchangeAuthCodeForOAuthTokens (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/recipe/thirdparty/providers/custom.js:259:23)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.signInUpPOST (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/recipe/thirdparty/api/implementation.js:26:36)
    at async Object.signInUpAPI [as default] (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/recipe/thirdparty/api/signinup.js:68:18)
    at async Recipe.handleAPIRequest (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/recipe/thirdparty/recipe.js:73:24)
    at async Recipe.handleAPIRequest (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/recipe/thirdpartyemailpassword/recipe.js:63:24)
    at async SuperTokens.middleware (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/supertokens.js:195:38)
    at async AuthMiddleware.supertokensMiddleware (/Users/nicola/Devel/temp/test-nest-app/node_modules/supertokens-node/lib/build/framework/express/framework.js:128:28)
    at async /Users/nicola/Devel/temp/test-nest-app/node_modules/@nestjs/core/router/router-proxy.js:9:17
I can correctly login on prebuilt ui but there's something weird going on on mobile.
r
The signinup api is returning a 500 error to the mobile client?
n
yes
I found the problem, the clients id mismatched. It is a little confusing in the docs how do clients have to match. Anyway this exception should be handled and return a coded error, right?
it is also a little confusing which client configuration is needed per thirdPartyId /platform pair
now facing issues on iOS simulator: same code, working on android (social login successful, test api call successful, logout successful, test api call rightly unsuccessful) but not on ios (exact same code, login successful, test api call failing, calls stops at nestjs authguard level, token not attached to request while in android is is)
after some reload and rebuild both platform work
r
great
yea, the docs can be a little confusing about this.. we will work on making it more clear! thanks
n
is there an explanation abt this?
Copy code
dart
 if (Platform.isAndroid) {
      googleSignIn = GoogleSignIn(
        serverClientId: "GOOGLE_WEB_CLIENT_ID",
        scopes: [
          'email',
        ],
      );
    } else {
      googleSignIn = GoogleSignIn(
        clientId: "GOOGLE_IOS_CLIENT_ID",
        serverClientId: "GOOGLE_WEB_CLIENT_ID",
        scopes: [
          'email',
        ],
      );
    }
why does apple (or not android actually, it is not clear if the counterparts are android and apple or the particular case is only android and all other follow the else statement) need both `clientID`and
serverClientId
?
r
it is android vs apple
n
so android uses the web
clientid
(in the google console the oauth code must be configured as web and not as android oath code) while apple needs both
clientid
(retrieved from an ios oauth credential created in the console) and
serverclientid
as per android? this is just to undestand the flow
in my case apple works only if configured as following:
Copy code
dart
googleSignIn = GoogleSignIn(
        clientId:
            "GOOGLE_IOS_CLIENT_ID",
        serverClientId:
            "GOOGLE_IOS_CLIENT_ID",
        scopes: [
          'email',
        ],
      );
on any other configuration the login call to supertokens backend fails with
Copy code
bash
[Nest] 49152  - 01/03/2024, 11:30:23 PM   ERROR [ExceptionsHandler] Received response with status 401 and body {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
as reported earlier
r
hmmm. This is different from what we expect
are you using react native?
n
this is a flutter project
r
right ok
so you already saw the example app
our example app does work
so im no sure why it's not working for you
n
im testing the same supertokens core and the same nestjs backend with both an angular project and a flutter project
r
right
do you pass the clientType when making the call to the
signinup
API?
n
I could make it work in the end, but settings needed to be trimmed a bit
of course otherwise it wouldnt have worked
I need to discriminate between ios and other frameworks
r
right yea
interesting..
maybe ill recheck the example app we have
n
actually there's a typo in the docs another guy already talked abt but seemed to be his own typo while instead is in the docs
Copy code
bash
curl --location --request POST 'http://localhost:3001/auth/signinup' \
--header 'rid: thirdpartyemailpassword' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{
    "thirdPartyId": "google",
    "clientType": "...",
    "redirecURIInfo": {
        "redirectURIOnProviderDashboard": "",
        "redirectURIQueryParams": {
            "code": "...",
        }
    }
}'
r
can't see the typo.. what is it?
n
redirecURIInfo
instead of
redirectURIInfo
r
ahh yea!
thanks!
n
in here https://github.com/supertokens/supertokens-flutter/blob/master/examples/with-thirdparty/lib/screens/login.dart the code is what I used but what makes it work or not are the code u put replacing the various clientIds
15 Views