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

Return expires_in in token endpoint's response. #170

Open
mohsinhijazee opened this issue Jan 27, 2025 · 1 comment · May be fixed by #187
Open

Return expires_in in token endpoint's response. #170

mohsinhijazee opened this issue Jan 27, 2025 · 1 comment · May be fixed by #187

Comments

@mohsinhijazee
Copy link

mohsinhijazee commented Jan 27, 2025

First of - brilliant piece of software with things distilled to the core.

One thing that I miss is that the OAuth spec recommends expires_in as part of the token endpoints response. Reference (not RFC) here. This allows lots of tooling (client libraries) to reuse the token expiry and refresh logic out of the box.

We already know the token expiry when we generate the token

async function generateTokens(/* all the params here */)
{

// Other stuff here....

 return {
      access: await new SignJWT({
        mode: "access",
        type: value.type,
        properties: value.properties,
        aud: value.clientID,
        iss: issuer(ctx),
        sub: value.subject,
      })
        .setExpirationTime(
          Math.floor((value.timeUsed ?? Date.now()) / 1000 + value.ttl.access),
        )
        .setProtectedHeader(
          await signingKey.then((k) => ({
            alg: k.alg,
            kid: k.id,
            typ: "JWT",
          })),
        )
        .sign(await signingKey.then((item) => item.private)),
      refresh: [value.subject, refreshToken].join(":"),
    }

}

It would be great if we include expires_in as part of the token endpoint's response. I can contribute a PR, don't have it though.

@thdxr
Copy link
Contributor

thdxr commented Feb 3, 2025

yep this is a missing feature we need to add, would def take a PR

@lettucebowler lettucebowler linked a pull request Feb 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants