Can't access management api although everything I want is just the publishedFirstAt Date.
See original GitHub issueWith the following code I’m trying to get access to the Management API. The only reason I even need this, is because I need one Date, the publishedAt-Date, which for some reason you don’t deliver via the Delivery API. So I really don’t wanna go through the whole oAuth do this do that 5 links 1h later it might finally work process, if it can somehow be done with the personal access token.
import * as contentful from 'contentful-management'
let client = contentful.createClient({
accessToken: <personal access token generated from web app>
})
client.getSpace(<space_id>)
.then((space) => space.getEntries())
.then((response) => console.log(response.items))
.catch(console.error)
But unfortunately all I’m getting is this error:
AccessTokenInvalid: "{
"status": 401,
"statusText": "Unauthorized",
"message": "The access token you sent could not be found or is invalid.",
"details": {},
"request": {
"url": "https://api.contentful.com:443/spaces/<space_id>",
"headers": {
"Accept": "application/json, text/plain, */*",
"X-Contentful-User-Agent": "sdk contentful-management.js/5.2.1; platform browser; os macOS;",
"Authorization": "Bearer ...qS4Ya"
},
"method": "get"
},
"requestId": "a9242e6926ac27d80cc43559df3aa38c"
}"
I’m working with Gatsby, if that is of any importance. I don’t know, why it’s not working. If somebody can point me in the right direction, it would be greatly appreciated.
Otherwise… Please Please Please add the publishing Dates to the Delivery API. There is no reason whatsoever to make it this hard to get that date.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Hi,
the code snippet you provided should work. Are you, by chance, using the
Content delivery token
? You need to create aContent management token
in the web app (https://app.contentful.com/spaces/<space_id>/api/cma_tokens
) and use it in your request.Let me know if that works for you!
@jroehl @phoebeschmidt
I got myself a new personal access token, which seems to be working now. Thank you very much for your willingness to help. Still wondering why that date is not getting shipped in the Delivery API, would be very useful imo.
Have a great day!