turbo clerk auth not working
Just cloned repo from official clerk-turbo template.
My app runs just fine, untill I try to log in.
I've changes oauth strategy to google, and it works.. kinda. It loads the browser, lets me provide all google credentials, lets me submit, but does not login. Just nothing. No errors, nothing.
all I did was change strategy to google, my signInWithOauth looks like:
Also I've noticed that SetActive, SignIn and SignUp are of type any. Should it be that way?
import { useOAuth } from "@clerk/clerk-expo";
import React from "react";
import { Button, View } from "react-native";
import { useWarmUpBrowser } from "../hooks/useWarmUpBrowser";
const SignInWithOAuth = () => {
useWarmUpBrowser();
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" });
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
console.log(signIn);
console.log(signUp);
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
return (
<View className="rounded-lg border-2 border-gray-500 p-4">
<Button title="Sign in with Google" onPress={handleSignInWithGoogle} />
</View>
);
};
export default SignInWithOAuth;
import { useOAuth } from "@clerk/clerk-expo";
import React from "react";
import { Button, View } from "react-native";
import { useWarmUpBrowser } from "../hooks/useWarmUpBrowser";
const SignInWithOAuth = () => {
useWarmUpBrowser();
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" });
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
console.log(signIn);
console.log(signUp);
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
return (
<View className="rounded-lg border-2 border-gray-500 p-4">
<Button title="Sign in with Google" onPress={handleSignInWithGoogle} />
</View>
);
};
export default SignInWithOAuth;
13 Replies
is this warning related?
Is there anything in the logs for signIn or signUp?
No
Are you sure?
Nothing about signIn and SignUp. Only about Linking
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
console.log(signIn)
console.log(signUp
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
console.log(signIn);
console.log(signUp);
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
console.log(signIn)
console.log(signUp
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
console.log(signIn);
console.log(signUp);
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
{"attemptFirstFactor": [Function anonymous], "attemptSecondFactor": [Function anonymous], "authenticateWithMetamask": [Function anonymous], "authenticateWithRedirect": [Function anonymous], "authenticateWithWeb3": [Function anonymous], "create": [Function anonymous], "createMagicLinkFlow": [Function anonymous], "createdSessionId": null, "firstFactorVerification": {"attempts": null, "error": {"code": "external_account_not_found", "longMessage": "The External Account was not found.", "message": "Invalid external account", "meta": [Object]}, "expireAt": 2023-05-24T14:20:19.911Z, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": "transferable", "strategy": "oauth_google", "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "id": "sia_2QF7LToBrk4mtS6yLGohpvgZbYq", "identifier": null, "pathRoot": "/client/sign_ins", "prepareFirstFactor": [Function anonymous], "prepareSecondFactor": [Function anonymous], "secondFactorVerification": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": null, "strategy": null, "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}, "status": "needs_identifier", "supportedFirstFactors": [{"strategy": "oauth_apple"}, {"strategy": "oauth_google"}, {"strategy": "oauth_discord"},
{"strategy": "ticket"}], "supportedIdentifiers": ["email_address", "username"], "supportedSecondFactors": null, "userData": null}
{"attemptFirstFactor": [Function anonymous], "attemptSecondFactor": [Function anonymous], "authenticateWithMetamask": [Function anonymous], "authenticateWithRedirect": [Function anonymous], "authenticateWithWeb3": [Function anonymous], "create": [Function anonymous], "createMagicLinkFlow": [Function anonymous], "createdSessionId": null, "firstFactorVerification": {"attempts": null, "error": {"code": "external_account_not_found", "longMessage": "The External Account was not found.", "message": "Invalid external account", "meta": [Object]}, "expireAt": 2023-05-24T14:20:19.911Z, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": "transferable", "strategy": "oauth_google", "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "id": "sia_2QF7LToBrk4mtS6yLGohpvgZbYq", "identifier": null, "pathRoot": "/client/sign_ins", "prepareFirstFactor": [Function anonymous], "prepareSecondFactor": [Function anonymous], "secondFactorVerification": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": null, "strategy": null, "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}, "status": "needs_identifier", "supportedFirstFactors": [{"strategy": "oauth_apple"}, {"strategy": "oauth_google"}, {"strategy": "oauth_discord"},
{"strategy": "ticket"}], "supportedIdentifiers": ["email_address", "username"], "supportedSecondFactors": null, "userData": null}
{"abandonAt": 1685023823952, "attemptEmailAddressVerification": [Function anonymous], "attemptPhoneNumberVerification": [Function anonymous], "attemptVerification": [Function anonymous], "attemptWeb3WalletVerification": [Function anonymous], "authenticateWithMetamask": [Function anonymous], "authenticateWithRedirect": [Function anonymous], "authenticateWithWeb3": [Function anonymous], "create": [Function anonymous], "createMagicLinkFlow": [Function anonymous], "createdSessionId": null, "createdUserId": null, "emailAddress": "[email protected]", "firstName": "PTS", "hasPassword": undefined, "id": "sua_2QF7M2RFivHtZYMpaf7wwTIqPR9", "lastName": null, "missingFields": ["username"], "optionalFields": ["last_name", "first_name", "oauth_apple", "oauth_google", "oauth_discord"], "pathRoot": "/client/sign_ups", "phoneNumber": null, "prepareEmailAddressVerification": [Function anonymous], "preparePhoneNumberVerification": [Function anonymous], "prepareVerification": [Function anonymous], "prepareWeb3WalletVerification": [Function anonymous], "requiredFields": ["email_address", "username", "password"], "status": "missing_requirements", "unsafeMetadata": {}, "unverifiedFields": [], "update": [Function anonymous], "username": null, "verifications": {"emailAddress": {"attempts": null, "error": null, "expireAt": 2023-05-24T14:10:24.010Z,
{"abandonAt": 1685023823952, "attemptEmailAddressVerification": [Function anonymous], "attemptPhoneNumberVerification": [Function anonymous], "attemptVerification": [Function anonymous], "attemptWeb3WalletVerification": [Function anonymous], "authenticateWithMetamask": [Function anonymous], "authenticateWithRedirect": [Function anonymous], "authenticateWithWeb3": [Function anonymous], "create": [Function anonymous], "createMagicLinkFlow": [Function anonymous], "createdSessionId": null, "createdUserId": null, "emailAddress": "[email protected]", "firstName": "PTS", "hasPassword": undefined, "id": "sua_2QF7M2RFivHtZYMpaf7wwTIqPR9", "lastName": null, "missingFields": ["username"], "optionalFields": ["last_name", "first_name", "oauth_apple", "oauth_google", "oauth_discord"], "pathRoot": "/client/sign_ups", "phoneNumber": null, "prepareEmailAddressVerification": [Function anonymous], "preparePhoneNumberVerification": [Function anonymous], "prepareVerification": [Function anonymous], "prepareWeb3WalletVerification": [Function anonymous], "requiredFields": ["email_address", "username", "password"], "status": "missing_requirements", "unsafeMetadata": {}, "unverifiedFields": [], "update": [Function anonymous], "username": null, "verifications": {"emailAddress": {"attempts": null, "error": null, "expireAt": 2023-05-24T14:10:24.010Z,
"externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot": "", "status": "verified", "strategy": "from_oauth_google", "supportedStrategies": [Array], "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "externalAccount": {"attempts": null, "error": null, "expireAt": 2023-05-24T14:20:19.911Z, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": "verified", "strategy": "oauth_google", "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "phoneNumber": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot": "", "status": null, "strategy": null, "supportedStrategies": [Array], "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}, "web3Wallet": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot":
"", "status": null, "strategy": null, "supportedStrategies": [Array], "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}}, "web3wallet": null}
"externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot": "", "status": "verified", "strategy": "from_oauth_google", "supportedStrategies": [Array], "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "externalAccount": {"attempts": null, "error": null, "expireAt": 2023-05-24T14:20:19.911Z, "externalVerificationRedirectURL": null, "nonce": null, "pathRoot": "", "status": "verified", "strategy": "oauth_google", "verifiedAtClient": undefined, "verifiedFromTheSameClient": [Function anonymous]}, "phoneNumber": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot": "", "status": null, "strategy": null, "supportedStrategies": [Array], "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}, "web3Wallet": {"attempts": null, "error": null, "expireAt": null, "externalVerificationRedirectURL": null, "nextAction": "", "nonce": null, "pathRoot":
"", "status": null, "strategy": null, "supportedStrategies": [Array], "verifiedAtClient": null, "verifiedFromTheSameClient": [Function anonymous]}}, "web3wallet": null}
```
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
```
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
Yeah so the reason that is happening.
With OAuth for Google password is skipped by username is not returned.
requiredFields": ["email_address", "username", "password"]
requiredFields": ["email_address", "username", "password"]
So I can't use google oAuth? there has to be some walkaround or a way to configure it
Of course you can.
you just have to handle it on your own.
Oh yeah sure, thanks
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
console.log(signIn)
console.log(signUp
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
// in here check for the missing requirements aka username. Add a way to captcha username. finish the flow.
// delete this error
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
const handleSignInWithGoogle = React.useCallback(async () => {
try {
const { createdSessionId, signIn, signUp, setActive } =
await startOAuthFlow();
if (createdSessionId) {
console.log(signIn)
console.log(signUp
setActive({ session: createdSessionId });
} else {
// Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard.
// in here check for the missing requirements aka username. Add a way to captcha username. finish the flow.
// delete this error
throw new Error(
"There are unmet requirements, modifiy this else to handle them",
);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
}
}, []);
omg now I get it
wow seams obvious all of a sudden
huge thanks