Admin
What's your code?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Admin
What's your code?
Rank 2: Process
account.createOAuth2Session('google', 'https://localhost:5173/creator', 'https://localhost:5173') I have used react router for providing the routes.
Moderator
You can't use localhost as a domain for Google Auth
Moderator
Google requires having a domain running
Moderator
Also localhost is not https
Moderator
Just http
Moderator
The error you're getting is due to that
Rank 2: Process
But I had used it earlier in one of my projects.
Moderator
Not sure, but last time I checked it required a domain. But in your case the problem seems to be you're using https instead of http in the URL
Rank 2: Process
Yes I will try that
Rank 4: Virtual Machine
I think the problem could be https + localhost
Admin
can you change that https to http?
Rank 2: Process
Yup! It's working now. Thanks!
Rank 2: Process
One more question, is there any way I can add roles, like I have two buttons one for logging in the creator and the other for logging in the editor. What I want to do is whenever either of the buttons is clicked the required role is added to the user.
Admin
Maybe you can use user labels: https://appwrite.io/docs/products/auth/labels
Rank 2: Process
Is there any way I can do this in React? Or should I create a separate node file?
Admin
Maybe create the account using an Appwrite function that can also assign the label
Rank 2: Process
Ok I'll try that
Rank 2: Process
I am trying to create an appwrite function for adding labels to a user. Here is the code: `import { Client, Users } from "node-appwrite";
// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }) => {
// Why not try the Appwrite SDK?
//
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
const users = new Users(client);
const promise = users.updateLabels(
req.user_id,
[ req.role ]
);
promise.then(function (response) {
console.log(response); // Success
return res.send(response); // Success
}, function (error) {
console.log(error); // Failure
return res.send(error); // Failure
});` In the appwrite I am getting this error (as shown in the image), what am I doing wrong? Need help.
Admin
what SDK version is listed in your package.json?
Admin
you're letting hte user add whatever label they want? that doesn't seem safe 🧐
Rank 2: Process
What I am trying to do is achieve role based routing, I want the users to either sign in as creator or editor. For this I have two separate buttons, when the user clicks on it the user will be authenticated and the required role will be added, I was thinking of passing the user id and the role through request headers. Is there any better way to do it?
Admin
At the very least you should validate the input.
Although, honestly, I would do this on the front end the same way you'd have a light theme vs dark theme and letting the user choose between the two
Rank 2: Process
Ok got it
Rank 2: Process
I was following the steps on contributing.md to setup the development environment, after running docker compose build I am getting this error. What I can understand is it is asking for node version 10 something, but when I tried to install this version using nvm it says "npm@10.1.0" is not a valid version or known alias.