How to access private/restricted apis & apiProducts of apigee Portals using say curl.

Hey there,

i have an integrated apigee portal which has few public accessible apis & api products and few restricted/private apis & api products.

Those api products are attached with respective Apps.

I have generated bearer access token using client/api key and secret key and using that token i'm trying to access resources of apigee portal url "https://syed-eval-oauth2appyprivateportal.apigee.io/portals/api/sites/syed-eval-oauth2appyprivatepor..." using below curl command

curl -v -i -H 'Content-Type: application/json' -H 'Authorization: Bearer db9EFys2FGWQ1uuGFqH0AQXMzuTU' https://syed-eval-oauth2appyprivateportal.apigee.io/portals/api/sites/syed-eval-oauth2appyprivatepor...

this command gives me below error message/ output

{"status":"error","message":"An unexpected error occurred (id: 527368721)","data":null,"request_id":null,"error_code":"527368721"}

So, How to access private/restricted apis & apiProducts of apigee Portals using say curl.

Quick response will be appreciated.

Feel free to ask anything relevant about this issue which i might have forgotten to mention.

Thanks & Regards

0 4 231
4 REPLIES 4

Not applicable

are you able to access other apis? The error is not hinting anything to access related issues.

It looks as if you're trying to access your API page in the portal url. In order to access the portal, you need to authenticate with a portal userid/password, not with the API client key and secret.

You should access the API endpoint instead. You can check what the API endpoint is in the proxy overview page

hi deboraelkin,

1. i have used my portal credentials to access this url resource, it returns me with error suggesting that url expects Bearer token (see response below)

curl -v -u syed@gmail.com:admin@123 https://syed-eval-oauth2appyprivateportal.apigee.io/portals/api/sites/syed-eval-oauth2appyprivatepor...

Response of above command:

HTTP/2 401

{"status":"error","message":"Authorization header malformed: expected \"Bearer <token>\" (id: 208422944)","data":null,"request_id":null,"error_code":"208422944"}

2. Just for information, i have generated access token on my proxies and i'm able to access them successfully like this proxy api (https://syed-eval-test.apigee.net/appy-api-private/v1).

This proxy is registered/added in API Product as "oauth2AppyPrivateProduct" having "private" access and this API product is added in portal as "oauth2AppyPrivatePortal" having "restricted" visibility.

Q1. Can I/We access this proxy api from portal url using java REST calls or using curl.

Q2. If Yes, how should we achieve this scenario?

Thanks & Reagrds

syed

If I understood correctly, you are trying to access the portal URL using Curl. That's not something that's supported. You can of course invoke the APIs directly using their endpoint, as you have already done.

It's not clear to me from your explanation whether you're also having problems accessing the API from the portal (as a user, not via curl). If that's the case, change your oauth endpoint to make sure it returns token.type= "Bearer" (By default, it's set to Bearer Token")