Back

account.createJWT is not a function

  • 0
  • Accounts
  • Web
  • Functions
djcali
3 Apr, 2023, 03:06

Hello, Trying to create a function in node. I followed the example on appwrite.io but receiving the acount.createJWT is not a function error when i run the function. I'm probably doing something wrong but any help is appreciated. Thanks

TypeScript
const client = new sdk.Client();
 client
    .setEndpoint('myendpoint')
    .setProject('myproject')
    .setKey(mykey)
const account = new sdk.Account(client);
const promise = account.createJWT();
TL;DR
The user is trying to create a function in Node using the Appwrite SDK but they are getting an error "account.createJWT is not a function". They are looking for help in resolving the issue. Solution: The user needs to update their code to include the userID and the expiration as parameters for the createJWT function. The correct syntax is: `account.createJWT(userId, expiration)`.
Drake
3 Apr, 2023, 03:11

ya you can't really do that...you create JWTs client side when a session exists

djcali
3 Apr, 2023, 03:13

ok cool, I wanted customize a form where a user can change their password if they forgot or whatever. I was going to create a function to do that.

djcali
3 Apr, 2023, 03:15

How would I get a jwt client side using flutter?

Drake
3 Apr, 2023, 03:16
djcali
3 Apr, 2023, 03:16

nvm, i found it in the docs

djcali
3 Apr, 2023, 03:18

Well I wanted a customized email, but I guess if that is the only way.

Drake
3 Apr, 2023, 03:20

I see...

I'm not quite sure why you want a JWT token for this...if they need to recover their password, they can't generate a JWT token 🧐

djcali
3 Apr, 2023, 03:25

Kind of learning this as I go. lol, that makes sense. I guess I will just use the account recovery endpoint

djcali
3 Apr, 2023, 03:29

I forgot, I couldn't use the email verification endpoint because in Flutter I am using goRouter and I couldn't get the params in the verification email to work with it. So i am sure it will be the same issue with the password recovery email. I'll give it a shot.

Drake
3 Apr, 2023, 03:34

Go router can't handle query params??

djcali
3 Apr, 2023, 03:37

Yes It can. But I was having trouble extracting them from the link for some reason. I'll have to revisit it. I think it had something to do with the % sign in the link, which I know is standard on the web. I believe goRouter worked when the params are like this www.example.com/param1/param2 Thats how I got it working with the email verification

Drake
3 Apr, 2023, 03:37

You could make functions...but you'll need to recreate everything the create recovery API does including managing the secret

Drake
3 Apr, 2023, 03:38
djcali
3 Apr, 2023, 03:38

😟

djcali
3 Apr, 2023, 03:39

Yep, here is an example in one of my routes. GoRoute( name: 'emailVerification', path: '/emailVerification/:userId/:secret', pageBuilder: (context, state) => MaterialPage<void>( key: state.pageKey, child: VerifiedEmailPage( userId: state.params['userId'], secret: state.params['secret'], )), ),

Drake
3 Apr, 2023, 03:40

You're using state.params. query params are in state.queryParams

djcali
3 Apr, 2023, 03:40

that is not query params I know, let me revist

djcali
3 Apr, 2023, 03:41

Thank You

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