Cannot open playground. "Your token is invalid"

prisma

#21

I solved this doing:

prisma local stop
prisma local start

#22

:see_no_evil: Sorry, bro…


#23

Here is my procedure

  1. notice! when you prisma deploy ,the endpoint is https://us1.prisma.sh/public-shellduck-987/movie ,when you past to browser notice the correct endpoint is https://us1.prisma.sh/public-shellduck-987/movie/dev.At the dev mode
  2. need a token Here is
    {
      "Authorization": "Bearer --token is here ,please delete short line--"}
  1. if you used to have graphcool server ,notice the query method
 const mu = `mutation createReactScript(
   $title: String! 
   $url: String,
){
  createReactScript(
   data:{title:$title,
            url: $url
}){
     id,
     title
  }

}`

need a data prefix

  1. when you use graphql-rquest , dont’t forget add token !
import { GraphQLClient } from 'graphql-request'
const endpoint = ' https://us1.prisma.sh/public-shellduck-987/movie/dev'
 
const mu = `mutation createReactScript(
    $title: String! 
    $url: String,
    
 
){
   createReactScript(
    data:{title:$title,
          url: $url
  }){
      id,
      title
   }
 
}`
 
const insertData={title:'Primsa homepage',url:'https://www.prismagraphql.com'}
const client = new GraphQLClient(endpoint, {
    headers: {
        "Authorization": "Bearer --token place  here ,please delete short line-- ",
    }
  })
const handlePrismaDataTemplate = R.curry((template, variables) => (
   client.request(template, variables).then(data => {
       return data
 })
))
 
const  waitForVariables=handlePrismaDataTemplate(mu);
const   res= awiat waitForVariables(insertData);
res.then(data=>console.log(data));

#24

@nilan so how should that work from the client? E.g. I dont have a token yet on the client when signing up, should it work with some server middleware or something?


#25

:tada: :tada:

Figured out my issue.

Something in the flow auto-generates an auth token, and saves your auth token into localstorage/cookies/cache somewhere. So if you say, start the project with the default mysecret123, but then change the auth token to something else, the old token will persist, and wreck your playground.

Resolved for me by:
opening the chrome console
typing localstorage.clear()
turning off the server
right clicking refresh and clearing the cache
starting the playground from the CLI.

I have no doubt you could probably also just generate a new token and put it in your headers, but I prefer the automatic way, especially when troubleshooting potential onboarding hiccups.


#26

Having a similary issue. I am able to access prisma from playground but from my react-apollo-client I am having this error when running through docker. If I run manually then there are no issues.

code:3015
message:"Your token is invalid. It might have expired or you might be using a token from a different project."
requestId:"local:api:cjiby7pns000808570qrg71yr"

#27

Same problem here. I can make calls to my Prisma server from the playground, but whenever I try to make a call to my GraphQL server and it makes a call to the Prisma server, it get the same error message: “Your token is invalid. It might have expired or you might be using a token from a different project.” This happens even after generating another prisma token and passing that in.

Prisma version: 1.6.3
Graphql-cli version: 2.15.8

I’m hoping updating Prisma to 1.8 may help get past the issue… Will report back if it does.


#28

I am facing this on 1.8.3 of prisma


#29

I tried disabling auth in my prisma.yml. From observing the output of my graphql server, it appears that some calls to the prisma server were succeeding inconsistently. For example, in my signup function, it would create an organization and then a user but then fail when trying to update the organization with the user info. But then on a second attempt, it might fail at the creating an organization step.

To be more specific, this is occurring for me when trying to deploy a prisma server on kubernetes using image prismagraphql/prisma:1.6.3 from dockerhub. Running the prisma server locally results in docker pulling from image prismagraphql/prisma:1.6, which is when I finally tried switching the base image.

SO I was finally able to get around this issue by switching the base image for my kubernetes deployment from prismagraphql/prisma:1.6.3 to prismagraphql/prisma:1.6 and now things are working as expected (i.e. not resulting in ‘Your token is invalid…’)


#30

I have got the same error
Message: Your token is invalid. It might have expired or you mightbe using a token from a different project., Location: undefined, Path: undefined [Network error]: Error: Your token is invalid. It might have expired or you might be using a token from a different project.

Prisma.yaml

        endpoint: https://eu1.prisma.sh/haider-malik-c1556sddd/had/dev
        datamodel: datamodel.graphql
        secret: mysecret33
        hooks:
          post-deploy:
            - graphql get-schema --project database

.graphqlconfig.yml

    projects:
      app:
        schemaPath: src/schema.graphql
        extensions:
          endpoints:
            default: http://localhost:4000
      database:
        schemaPath: src/generated/prisma.graphql
        extensions:
          prisma: database/prisma.yml

#31

I generated JWT token by using prisma token . I am trying to access data from local default server. I provided the prisma generated token in Http Headers. Token is not working on local default server. This token is working on the database server
Here is my config file

projects:
  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: http://localhost:4000
  database:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: database/prisma.yml

Could you help me how to resolve this issue?


#32

you need to check if you pass the same secret that defined in prisma.yml in your prisma db

prisma%20secret


#33

Thanks ahrbil, I resolved this issue. I did not pass the secret into the options


#34

I was facing the same issue and I confirm that the solution from @ahrbil worked just fine. Thanks.