Micro Gateway: Unable to do Secure API calls to verify the token for edge aware proxy with OAuth2 access token

I am using Windows OS to configure the edge micro gateway for Private APIGEE cloud.

Steps followed for Secure API call with Oauth2 access:

1. Generated the key and secret using the below command:

edgemicro private configure -o cmpps -e dev -u test@test.com -p Apigee@dmin -r http://dev.cmpps.com:9004 -m http://10.1.***.**:8080 -v default

2. Created a edge-aware proxy with Authorization OAuth 2.0.

3. Created Product and added the edge-aware proxy and edgemicro-auth.

4. Started the Edge Micro successfully using the key and secret.

5. Generated the bearer token using edgemicro-auth api with grant_type = client_credentials and the user name and password same as in the Developer App.

Using the bearer token to call the edge aware proxy API, but getting the Invalid Access token.

Attaching the screenshot for more details.

Can anyone help to resolve the issue?

0 15 471
15 REPLIES 15

sydub7
New Member

1. You have to create a product which includes edgemicro-auth and your edgemicro_hello proxy. Create an App and tie it up with this Product)

2. Reload the micro gateway

3. Generete OAuth Token with client_credential grant type using edgemicro-auth token endpoint.(Use client_id and client_secret generated from the App from Step#1)

4. Attach the token as bearer when you are calling edgemicro_hello proxy.

5. When calling edgemicro_hello proxy use http://hostname:portnumberinconfig/hello or whatever is the the path. Here hostname is where the microgateway is installed.

5. You cannot trace this proxy as its executes on your machine and not on Apigee Edge.

@Sid Thanks for the response.

I have followed the same steps as you mentioned. Still getting the same response.

As the proxy is deployed in Private APIGEE we should able to track it right?

Hello Shalini, Not sure why you should get an error. Can you share some screenshots or curl requests for 1. Generation of Token using edgemicro-auth 2. Invocation of you edgemicro_ proxy ?

Please find the screen shot which includes Token generation and API call using Curl:

token-generation-and-api-call.png

1st call is fine where you get the token.

in 2nd call you don't use Apigee Edge URL instead use the URL where the Microgateway is deployed and running .(your windows machine)

The 2nd call URL should look like

http://{hostname_of_your_windows_machine:port_number_in_your_microgateway_config_file/hello

example: http://shalini_pc:8000/hello

8000 is the default port configured and can be changed in your microgateway config file located at .edgemicro directory on your windows machine

Thanks for the response. I followed the above steps and able to get the expected result.

Get call is working with the security but POST call is not working throwing 502 Bad Gateway. if I directly hit the API I am getting response for POST call. Any idea why none of the API call is working apart from GET verb call.

Error:

{"message":"read ECONNRESET","errno":"ECONNRESET","code":"ECONNRESET","syscall":"read"}

@Sid

Can you please help to resolve the issue.

can you share the curl request for this POST call ?

Can you stop and start the microgateway again ? Please share the console logs. Also please share the proxy configuration or upload the bundle if you may.

  • Currently we created and deployed edge aware proxy with Pass through (none).
  • Able to call GET API but not able to call POST/PUT API call even with no security.
  • When we try to call API(POST) from edgemicro ,we are able to hit the backend and the backend api is providing successful response but from microgateway we are getting the 502 Bad Gateway.
  • Attaching the files for APIGEE api call and edgemicro curl command.

Log File Screenshot

Edge API Call

No Security apigee api call

the error 'socket hang up' is logged into your log file. You can try following

1. stop edgemicro. Make sure node process is killed at port 8000

2. kill/rm edgemicro.sock process. It should present one level up .edgemicro directory

3. start edgemicro

4. Test again

  • That socket issue due to another API call whose Target End point is not listening.
  • Followed the above steps to started the edgemicro still unable to call POST call
  • Tried with security and without security but same response.
  • logfile1.png