Back

Creating JWT via Appwrite REST API

  • 0
  • Web
Dennis Ivy
20 Aug, 2023, 23:58

My goal is to generate a JWT via a REST endpoint. To the best of my knowlege, in order to accomplish this I am to send a POST request to the following endpoint, /v1/account/jwt along with the following headers: X-Appwrite-Project, X-Appwrite-Key and Content-Type. Following these instructions here: https://appwrite.io/docs/client/account?sdk=web-default#accountCreateJWT

My assumption is that I would also need to send along my email and password in the request body.

Any chance I am missing something here?

Here is the most common response I am getting:

TypeScript
{
    "message": "app.64abac5981e--------a@service.---.190.---.131 (role: applications) missing scope (account)",
    "code": 401,
    "type": "general_unauthorized_scope",
    "version": "1.3.7"
}
TL;DR
The user is trying to generate a JWT (JSON Web Token) through a REST API endpoint. They are following the instructions provided in the documentation, but they are encountering an error message stating that their email and password are missing the scope. The user is seeking clarification on what they might be missing. Solution: The user needs to add the "account" scope for the specified role ("applications") in order to generate the JWT successfully.
Dennis Ivy
21 Aug, 2023, 00:00

I have been able to accomplish this from the client side Via the WebSDK but I was hoping to have an endpoint I can test with in production without needing a client interface.

Drake
21 Aug, 2023, 00:10

You're right, you need a session before you can call the create JWT endpoint.

Btw to see how to make a rest API call, you can select REST for the client dropdown

Drake
21 Aug, 2023, 00:11

also, all our sdks use the rest APIs so you can also look at the source code for the sdks to see what it's doing

Dennis Ivy
21 Aug, 2023, 00:20

Ah good call. I'll see if I can find what I need in the source code, thanks Steven 🙂

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