Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Make an authenticated request to the API #39

@amaury1093

Description

@amaury1093

I'm trying to make an authenticated request from the frontend to the backend.

The overall authentication scheme is the following:

  • frontend makes a direct call to Auth0, authenticates, and gets back an authToken.
  • frontend makes a request to backend, with Authorization: 'Bearer ${authToken}', and the request should be authenticated.

Repro

  • frontend makes a call to Auth0 to get authToken, this works and can be done on chronoscio.now.sh, after login, go see the IndexDB storage of the web page (in the console Storage tab), and extract the idToken.
  • curl -X GET localhost/api/nations/ -H 'Content-Type: application/json' -H 'Authorization: Bearer /* copy paste the id token*/'
    • note: GET shouldn't require auth on that endpoint, but is simpler to type here. The same behavior appears for POST too.

Expected
200 response

Actual
401 "Incorrect authentication credentials."

I'm pretty sure it has to do with wrong CLIENT_IDs set somewhere, or wrong permissions between apps in Auth0, but can't figure where.

screen shot 2018-09-26 at 13 45 04

Notes

  • The app the frontend is connecting to is ChronoScio [DEV].
  • If I use the django (test) application, and take the access_token given by this api, it works.
  • I'm pretty sure the idToken given to the frontend by Auth0 is correct: I sometimes see Signature expired, and if I use another token then it just returns another error ("Invalid token").

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions