Back

User (role) missing scope (account)

  • 1
  • Web
Binyamin
25 May, 2023, 02:54

Is the login work, and you want to be able to get the user profile image?

TL;DR
User is asking for help with setting up database initialization after authentication and checking if a user already exists. They are also having trouble getting the user profile image. The solution provided is to use the appropriate AppWrite functions for user creation and retrieval, such as account.create() and account.get(). Additionally, they are advised to use the appropriate SDK (Server SDK or client-side SDK) depending on their needs.
Saswat
25 May, 2023, 02:55

Yup I did a work around but it was hectic....If I want create a new User in database. How should I do that ?

Saswat
25 May, 2023, 02:56

Yup I want to get user profile image.

Binyamin
25 May, 2023, 02:57

For just creating user programmatically use the Users Server SDK You can use any of the create functions here: https://appwrite.io/docs/server/users

Saswat
25 May, 2023, 02:59

The sdk is for server side. I want to create users in the client side.

Binyamin
25 May, 2023, 02:59

You'll have to do it manually I think.

For Github for example you can use https://api.github.com/search/users?q=torvalds

Binyamin
25 May, 2023, 03:01
Drake
25 May, 2023, 03:01

Why? What exactly are you trying to do?

Saswat
25 May, 2023, 03:02

What should be the flow creating the user like first check if it is already exist in the database if not create then

Drake
25 May, 2023, 03:03

Are you trying to let users sign up/create their account for your app?

Saswat
25 May, 2023, 03:04

I guess when the user gets logged in during that point of time userData sets to null. That's why I was not able to get the data. So what I did was I waited for the user to log in then after that get the account.get()

Saswat
25 May, 2023, 03:04

Yes sir

Drake
25 May, 2023, 03:05

Yes, account.get() needs to be called after a session is created

Saswat
25 May, 2023, 03:06

Yup It was not working in the same function even if I use async await

Drake
25 May, 2023, 03:06

Creating an oauth2 session will automatically create a user if they don't exist.

Otherwise, you can use account.create()

Saswat
25 May, 2023, 03:07

I want to store that data in the database.

Drake
25 May, 2023, 03:07
Saswat
25 May, 2023, 03:09

It will be better if we could call it in the same function with then and catch statements

Saswat
25 May, 2023, 03:09

How to do that ?

Drake
25 May, 2023, 03:16

You can't because that's not how the OAuth2 works...the create oauth2 session function opens a new tab/window for the oauth2 flow. After the tab is created, execution continues, but the session hasn't been created yet

Saswat
25 May, 2023, 03:36

okk. Thank you sir got it. Could help how to setup intialise database with name and email after authentication. And also check it already exists ?

Drake
25 May, 2023, 03:40

Maybe you should read up on database design first. This is a little outdated, but principles still apply https://dev.to/appwrite/30daysofappwrite-database-design-140a

Saswat
26 May, 2023, 12:04

How to get the spotify Authorisation token when logging through AppWrite ?

Guille
26 May, 2023, 12:57

Are you using nextjs for the frontend?

Drake
26 May, 2023, 15:13

providerAccessToken from the OAuth2 Session: https://appwrite.io/docs/models/session

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more