Rank 1: Thread
Hello,
I am using appwrite and I need to pass client's jwt to an api route so that api route can make additional validations on the server meanwhile only being in the scope of local user's permissions.
Now we are using OAuth to authenticate our users, problem is that when I generate a JWT token like this:
const jwt = await account.createJWT() - this is on the client
it returns a normal valid token like this: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiI2NWQwZjZiMjQ4YzMwMTdiNzA3YSIsInNlc3Npb25JZCI6IjY1ZDEwMzFkNDQzYWJkMmM2MDBiIiwiZXhwIjoxNzA4NjIzMjY1fQ.V46zLFgFf3XQR0zUxK6XtTxjJUVBMEnowW5ZJBSDT7s
However when I try to do something with the token like this:
client.setJWT(jwt); - this is inside of the api route
I get the following error:
{ code: 401, type: 'user_jwt_invalid', response: { message: 'Failed to verify JWT. Invalid token: Incomplete segments', code: 401, type: 'user_jwt_invalid', version: '1.4.9' }}I've seen some older post where someone suggested to use client.setKey(jwt) instead of the client.setJWT(jwt), however in that case I get the following error:
{ code: 401, type: 'user_unauthorized', response: { message: 'Permissions must be one of: (any, guests)', code: 401, type: 'user_unauthorized', version: '1.4.9' }
}I really have no idea what this is causing, hope to see your ideas soon.