Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with API call #38

Closed
gcornetta opened this issue Oct 8, 2017 · 4 comments · May be fixed by #191, #197 or #203
Closed

Trouble with API call #38

gcornetta opened this issue Oct 8, 2017 · 4 comments · May be fixed by #191, #197 or #203
Labels

Comments

@gcornetta
Copy link

Hi,

I have successfully installed and configured the API gateway. I can call the /users/authentication and get the JWT token to authorise the APIs call; however, when I try to call an API (for example to register a new user) I receive a 401 response. Looking at the error stack it seems it is a passport authentication error.

Could you please help me solving this issue? Thank you so much in advance.

@thiagobustamante
Copy link
Collaborator

thiagobustamante commented Oct 9, 2017

Hi,

How are you passing the token to the tree-gateway Endpoints? You need to add the token in the 'Authorization' header, setting the schema to 'JWT'.

'Authorization': 'JWT <your token here>'

You can test it through the swagger-ui available at:

http://localhost:8001/api-docs

Click on the red exclamation mark next in the endpoint box to authenticate.

captura de tela 2017-10-08 as 23 03 19

And about the error message. The error stack trace is appearing because you are running the gateway in development mode. If you set the NODE_ENV variable to production, the stack trace will not be sent to the browser.

@gcornetta
Copy link
Author

Hi,
Thank you so much for your prompt response. I used the swagger-hi interface and pasted the Generated JWT token. Then I tried to perform some operations, e.g. adding a new user, as I explained in my previous mail, unfortunately, no matter what kind of of operation I was trying to do, the response from the server was always 401, And I cannot figure out what I am doing wrong.

@thiagobustamante
Copy link
Collaborator

Hi,
If you are receiving a 401 code, the problem is occurring when the admin module tries to validate your token. Can you post your tree-gateway.yaml configuration file here and show me the request you are doing? You can copy the 'curl' command for your request from the swagger-ui client:

captura de tela 2017-10-10 as 14 39 19

With the gateway configuration and the curl request command, I can reproduce the problem here and help you properly.

Thanks.

@license2e
Copy link

@gcornetta I initially ran into the same issue, until I realized that I needed to use JWT <token> when I was using the swagger api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants