Back

An error occurred: app.66b0ff530019305177ae@service.cloud.appwrite.io (role: applications) missing

  • 0
  • Cloud
Rinae
5 Sep, 2024, 13:53

When creating jwt token I get this error

An error occurred: app.66b0ff530019305177ae@service.cloud.appwrite.io (role: applications) missing scope (account)

Here's my code.

try { $session = $account->createEmailPasswordSession($email, $password); $jwt = $account->createJWT();

TypeScript
    return $context->res->json([
        'status' => 'success',
        'session' => $session,
        'jwt' => $jwt
    ]);
} catch (Exception $e) {
    $context->log('General Exception: ' . $e->getMessage());

    return $context->res->json([
        'status' => 'error',
        'message' => 'An error occurred: ' . $e->getMessage()
    ]);
}

Session gets created successfully but jwt token returns the above error

TL;DR
The error occurs because the API key is missing the required scope. Try removing the API key, which should resolve the issue. Code works fine when the $jwt = $account->createJWT(); line is commented out.
ideclon
5 Sep, 2024, 13:56

Did you set an API key?

Rinae
5 Sep, 2024, 13:57

Yes I did. Everything was working perfectly until I add this line $jwt = $account->createJWT();

Rinae
5 Sep, 2024, 13:57

If I comment it out my code works without any issue

ideclon
5 Sep, 2024, 13:58

Try removing the API key

ideclon
5 Sep, 2024, 13:58

(Unless there are other places in your code you need it?)

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