#Redirect Uri
23 messages · Page 1 of 1 (latest)
What is giving this error?
Oauth?
appwrite Oauth
Can you provide the code?
the problem is in the login function it works using the localhost
Did you register the domain you're using as a platform? Are you using cloud?
yes lm using cloud
Redirect uri should be appwrite-callback-<projectId
And next time instead of providing the whole codebase just provide the function code
so how to ensure that the url is appwrite-callback-<projectId and also why is working well on localhost expo go
It was working with expo go as appwrite implemented a new method that will work with expo.
But for built app they check for scheme
Go to app.json and set the scheme as required.
That should do the work
try {
const deepLink = new URL(makeRedirectUri({ preferLocalhost: true }));
const scheme = `${deepLink.protocol}//`; // e.g. 'exp://' or 'appwrite-callback-<PROJECT_ID>://'
const response = await account.createOAuth2Token(
OAuthProvider.Google,
`${deepLink}`,
`${deepLink}`,
);
if (!response) throw new Error("Create OAuth2 token failed");
const browserResult = await openAuthSessionAsync(
response.toString(),
scheme
);
if (browserResult.type !== "success")
throw new Error("Create OAuth2 token failed");
const url = new URL(browserResult.url);
const secret = url.searchParams.get("secret")?.toString();
const userId = url.searchParams.get("userId")?.toString();
if (!secret || !userId) throw new Error("Create OAuth2 token failed");
const session = await account.createSession(userId, secret);
if (!session) throw new Error("Failed to create session");
return true;
} catch (error) {
console.error(error);
return false;
}
}``` Now its failing to send a request above is my login function. I changed my scheme in my app.json scheme: "appwrite-callback-projectid"
Any errors?
failed to connect from my try and catch
cc: @fleet willow 🙂
What line exactly throws the exception?
OAuthProvider.Google,
`${deepLink}`,
`${deepLink}`,
);``` how arguments does this function take
The problem is createOAuth2Token does not return any data, you should be able to create the session from the callback, check this post: https://appwrite.io/blog/post/fixing-oauth2-issues-in-appwrite-cloud
I dont think this is the problem.
The blog says to use the token method instead of session method.
Also I am doing the same in oauth. I did not face this.
Would you please log account.client.config right before this?
Also, please check the network logs from the dev tools