Back

Error when create account

  • 1
  • Flutter
mo7amedtech
3 Jul, 2023, 06:17

Hello i tried to create account by SDK but told me failed host name however application add to cloud.appwrite success . and package name ia true .

TL;DR
User is experiencing an error when trying to create an account using the SDK. They are getting an "unauthorized_scope" error when removing a header. Another user suggests initializing the client object properly and not setting headers manually. They provide code examples for the correct initialization. The user with the issue is asked to share their relevant code.
safwan
3 Jul, 2023, 07:24

What's the endpoint you used for initializing client in your code?

mo7amedtech
3 Jul, 2023, 11:15

Cloud.appwrite.io

mo7amedtech
3 Jul, 2023, 11:15

@safwan Cloud.appwrite.io

mo7amedtech
3 Jul, 2023, 12:35

؟؟

Maniac_Fighter
3 Jul, 2023, 12:42
mo7amedtech
3 Jul, 2023, 12:53

@Maniac_Fighter yes

Maniac_Fighter
3 Jul, 2023, 12:54

Can you share the relevant code?

mo7amedtech
3 Jul, 2023, 12:56

@Maniac_Fighter ok min

mo7amedtech
3 Jul, 2023, 13:02

Here is my code

Maniac_Fighter
3 Jul, 2023, 13:07

Let's do one thing,

Initialise your client object once( it's fine if you keep it global). Make sure you set all these things before passing the object to other services

so instead of the above do something like this

TypeScript
final Client client = Client().setEndpoint("YOUR_ENDPOINT").setProject("YOURPROJECTID");

Then

TypeScript
Account account = Account(client);

You should pass the object only after you initialised the client properly.

Maniac_Fighter
3 Jul, 2023, 13:08

No need for setSelfSigned and addHeader . SetSelfSigned is depreceated now No need to add headers as the SDK automatically adds this for you

mo7amedtech
3 Jul, 2023, 13:09

Ok i will try now

mo7amedtech
3 Jul, 2023, 13:15

@Maniac_Fighter thank you very much but when remove header give me unauthorized_scope

Maniac_Fighter
3 Jul, 2023, 13:17

create method only creates a new account in the cloud. It does not create a new session. You need to call the https://appwrite.io/docs/client/account?sdk=web-default#accountCreateEmailSession then you could update the prefs

joeyouss
3 Jul, 2023, 13:19

oops, realised I sent the same links as Biswa

mo7amedtech
3 Jul, 2023, 13:20

@Maniac_Fighter I need to store role in prefs in create account to check account role

mo7amedtech
3 Jul, 2023, 13:22

@Maniac_Fighter i will store in database collectiob better then call it when signin

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