Giter Club home page Giter Club logo

Comments (6)

KacperBiedka avatar KacperBiedka commented on July 30, 2024 4

Might be late for this, but in my case it was the difference between tokens, the contentful-management library requires a different type of token that you can find under this section in settings > api keys

image

from contentful-typescript-codegen.

sahildeliwala avatar sahildeliwala commented on July 30, 2024

@AlexandreVerhoye it seems you need to return space.getEnvironment("master")

can you try this?

const contentfulManagement = require("contentful-management");

module.exports = function () {
  const contentfulClient = contentfulManagement.createClient({
    accessToken: "myaccesstoken",
    host: "cdn.contentful.com",
  });

  return contentfulClient.getSpace("myspaceid").then((space) => {
    return space.getEnvironment("master");
  });
};

from contentful-typescript-codegen.

AlexandreVerhoye avatar AlexandreVerhoye commented on July 30, 2024

Hey, now I have this error :

NotFound: {
  "status": 404,
  "statusText": "Not Found",
  "message": "The resource could not be found.",
  "details": {},
  "request": {
    "url": "/spaces/xxxxxxxxx/environments/master",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "sdk contentful-management.js/7.45.0; platform node.js/v14.18.1; os macOS/21.1.0;",
      "Authorization": "Bearer xxxxx",
      "user-agent": "node.js/v14.18.1",
      "Accept-Encoding": "gzip"
    },
    "method": "get"
  },
  "requestId": "xxxxxx"
}

from contentful-typescript-codegen.

sahildeliwala avatar sahildeliwala commented on July 30, 2024

@AlexandreVerhoye hmmm... can you try just this?
and make sure the Access token you add is your Personal Access Token.
omit host and try.

const contentfulManagement = require("contentful-management");

module.exports = function () {
  const contentfulClient = contentfulManagement.createClient({
    accessToken: "myaccesstoken", 
  });

  return contentfulClient.getSpace("myspaceid").then((space) => {
    return space.getEnvironment("master");
  });
};

from contentful-typescript-codegen.

AlexandreVerhoye avatar AlexandreVerhoye commented on July 30, 2024

I'm getting this error :

AccessTokenInvalid: {
  "status": 403,
  "statusText": "Forbidden",
  "message": "The access token you sent could not be found or is invalid.",
  "details": {},
  "request": {
    "url": "/spaces/xxxxx",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "sdk contentful-management.js/7.45.0; platform node.js/v14.18.1; os macOS/21.1.0;",
      "Authorization": "Bearer ...xxxx",
      "user-agent": "node.js/v14.18.1",
      "Accept-Encoding": "gzip"
    },
    "method": "get"
  },
  "requestId": "c1d77801-035f-4a69-b6de-3ba849d66d38"
}

They are the same credential I'm using to fetch data on my nextjs project

from contentful-typescript-codegen.

jaec0113 avatar jaec0113 commented on July 30, 2024

Based on my experience (and another issue posted here), it seems like if you are trying to hide your info in an environment variable and then access them in the .getContentfulEvironment.js file then it doesn't work properly (I got the exact same error messages). Once I hard entered the token, space, and environment names into the file it worked perfectly.

from contentful-typescript-codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.