RinaeOriginal post
Rank 1: Thread
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();
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
Summary
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.