question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't access management api although everything I want is just the publishedFirstAt Date.

See original GitHub issue

With 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jroehlcommented, Sep 25, 2019

Hi,

the code snippet you provided should work. Are you, by chance, using the Content delivery token? You need to create a Content 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!

0reactions
odalysadamcommented, Oct 1, 2019

@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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: User Management API (Cloud) - Unable to access
Solved: I've been turning myself inside out trying to access the User Management API for Jira Cloud. I'm using Google Apps Script, ...
Read more >
What is API Access Management? - YouTube
APIs are a simplified way for computers to share data or integrate their functionality. But they're also the next big security threat.
Read more >
Using the Identity Management API to Communicate with the ...
This document describes how to access the Identity Management (IdM) management framework in a programmatic way remotely over the HTTPS ...
Read more >
Azure AD identity and access management API overview
Use Azure Active Directory (Azure AD) to manage identities and devices and control access in on-premises, hybrid, and cloud environments.
Read more >
Everything You Need to Know About Identity and Access ...
API key security functions through the use of cryptographic tokens just like many other IAM tools but also works great when developed in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found