How to request and pass an oauth token for REST API access in OpenShift 4

Solution Verified - Updated -

Issue

  • Getting HTTP 403 error when making a request to the OpenShift REST API.
    Example:
$ curl -s -k -X GET https://api.example.com:6443/apis/project.openshift.io/v1/projects

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "projects.project.openshift.io is forbidden: User \"system:anonymous\" cannot list resource \"projects\" in API group \"project.openshift.io\" at the cluster scope",
  "reason": "Forbidden",
  "details": {
    "group": "project.openshift.io",
    "kind": "projects"
  },
  "code": 403
  • How to make REST API calls with curl to OpenShift ?

Environment

  • Red Hat OpenShift Container Platform (RHOCP) 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content