jaredhanson / jaredhanson/oauth2orize

Correct way to access the "request" object during "token endpoint".

Open
#182 17 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.5k
Forks
472
PR merge metrics
No merged PRs in 30d

Description

I want to access the request object of the token endpoint so that I'll know the request headers accessing it.

As shown in this section:

app.post('/token',
  passport.authenticate(['basic', 'oauth2-client-password'], { session: false }),
  server.token(),
  server.errorHandler());

I understand that the server.token() part returns the access tokens in the response of the POST /token endpoint.

So I tweaked that part to in order for me to access the request object which got me here:

app.post("/token", 
     passport.authenticate(['basic', 'oauth2-client-password'], { session: false }), (request, response) => {
   // Now where to implement this?
  // server.token();
  console.log(request.headers);
  response.status(200).json({access_token: 'asfdasfd', expires_at: 'asdfasdf', token_type: 'asdfasdf'});
});

I can access the request headers but now I cannot get the right tokens. Is there anyway to implement this correctly?

thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the token endpoint entry point shown in the issue: the app.post('/token') middleware chain using passport.authenticate, server.token(), and server.errorHandler(). Trace how server.token() produces the access-token response while preserving access to the request headers. Done means the endpoint exposes the needed request information and still returns the correct tokens.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript
Domain
api, authentication, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.