Cannot open playground. "Your token is invalid"


#1

I’ve created multiple projects on my local cluster, so I guess I’m using a wrong token in the playground. How can I fix this?

{
  "code": 3015,
  "requestId": "api:api:cjck7wz6o000k0190exc6vs25",
  "error": "Your token is invalid. It might have expired or you might be using a token from a different project."
}


#2

I had this problem several time too.

I temporally set disableAuth: true and comment out secret for a while.


#3

I already tried that. Didn’t work for me.


#4

Your service is protected with a secret, to prevent malicious access. This applies to GraphQL operations, as well as sending an introspection query (which happens when opening the URL in the Playground).

The secret can be found in prisma.yml, it is actually one string that is a comma separated list of secrets, to allow for secret rotation without downtime.

You can generate a token that is signed with a secret using the prisma token command.

Then, set your query headers to this:

{
  "Authorization": "Bearer <token>"
}

You can read more about authentication here: https://www.prismagraphql.com/docs/reference/prisma-api/concepts-utee3eiquo#authentication


Confused with secrets
#5

Disabling auth doesn’t work :frowning:


#6

Hey @Terion, can you elaborate?

There are two known issues with disableAuth right now, and both are easy to workaround:

Please follow the instructions there, to see if you are encountering a separate issue.


#7

I’ve set disableAuth: true in prisma.yml, commented out secret: mysecret123 and secret: 'mysecret123' in index.ts, restarted service and still get token error in http://localhost:4466/hello-world/dev

Providing token there works, but it has no sense (but schema explorer doesn’t work still)

Also it is not clear what is sense in two playgrounds, http://localhost:4466/hello-world/dev and http://localhost:3000/playground that is started . by yarn dev


#8

Did you deploy after making these changes?


#9

It refuses to deploy:

$ prisma deploy
Deploying service `hello-world` to stage `dev` on cluster `local` 448ms
Service is already up to date.

#10

Looks like you are encountering https://github.com/graphcool/prisma/issues/1433. While the CLI reports that “Service is already up to date”, the change should have been registered.


#11

nope. still Your token is invalid


#12

Please describe the steps you took to get here :slight_smile:


#13
  • run prisma init hello-world
  • setup a simple ts demo project with local cluster
  • run prisma deploy
  • open playground on http://localhost:4466/hello-world/dev and see token error
  • set disableAuth: true in prisma.yml, comment out secret: mysecret123
  • comment out secret: ‘mysecret123’ in index.ts
  • run prisma deploy
  • nothing changes

#14

What’s your prisma version? prisma -v


#15

$ prisma -v
prisma/1.0.4 (darwin-x64) node-v9.4.0


#16

I think I have a similair issue, when I disableAuth in prisma.yml it doesn’t pick up the changes when I run prisma deploy and just says Service is already up to date. When I then add and remove a field in my database/datamodel.graphql the service picks up my changes and disables auth. So far that’s annoying but I can work around it, the issue then is that my deployed endpoint doesn’t have access to my custom resolvers anymore and the playground doesn’t show the App tab. When I run it locally it does show the App tab and my custom resolvers. @nilan do you have any idea what I’m doing wrong with my deployed version?


#17

Same here.
local (in docker) and also on eu1.prisma


#18

I was not able to reproduce this issue so far. Do you have different reproduction steps, @eiss.tobias?


#19

prisma/1.0.0 (darwin-x64) node-v9.4.0
With following steps i can reproduce this every time:

prisma init
-> GraphQL server/fullstack boilerplate
-> node-basic
-> local (with docker)

cd <projectname>
prisma deploy

Then call in browser: http://localhost:4466/<projectname>/dev:

{
  "code": 3015,
  "requestId": "api:api:cjcu7ba6o000b01365xm84r65",
  "error": "Your token is invalid. It might have expired or you might be using a token from a different project."
}

#20

Hey @tobi, this looks to be a misunderstanding.
The steps you describe and the outcome are all expected.

Please read my reply further up in this thread: Cannot open playground. "Your token is invalid"

Hope that helps! :slight_smile: