Invalid_request error during OAuth flow in API Portal
search cancel

Invalid_request error during OAuth flow in API Portal

book

Article ID: 203213

calendar_today

Updated On:

Products

CA API Developer Portal

Issue/Introduction

I try to use Portal Metrics API on our tenant of our Portal 5.0, first  i try to obtain Access Token. 

As first step, I send GET request (I use Postman):

'https://apim-ssg.portaldomain:9443/auth/oauth/v2/authorize?client_id=<client_id>&response_type=code&scope=OOB&redirect_uri=https://apim.portaldomain/admin/oauthCallback&state=abcde&client_secret=<client_secret>

client_id, client_secret, scope and redirect_uri are taken from Application Configuration.

As the response, I got html page. Then I save this response on disk as login.html, open this in the browser, and I input username and password of user who has  access to this application.

So I got response from https://apim-ssg.portaldomain:9443/auth/oauth/v2/authorize/login:

OAuth 2.0 Authorization Server

error: invalid_request
error_description: The resource owner could not be authenticated due to missing or invalid credentials

 

Environment

Release : 5.0

Component : API PORTAL

Resolution

The following steps should resolve the error and allow to acces the metrics api :

Make sure that you assign the Login API , the Portal Metrics API and Reference Portal RBAC API (read only) to the app you created for this in portal.

To get a bearer access token using postman :

https://apim-ssg.portaldomain:9443/auth/oauth/v2/token?grant_type=client_credentials&scope=OOB

HTTP Method: POST
Request URL: Token Endpoint
Authorisation: Basic Authentication (user is the 'API Key' and password is the 'Shared Secret')
Headers: Content-Type 'application/x-www-form-urlencoded'


This will return a bearer token in the response, here an example:

{
"access_token": "4f0c0cf5-f9d3-4c02-8fce-067816cb44fe",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "oob"
}

This bearer token can be used In a get metrics api call 

https://apim-ssg.portalfdomainl:9443/tenantname/analytics/metrics/v1/errors/apis?timerange=month&sortorder=desc&sortby=errors