Skip to content

[RFC]: AuthContextInterface should support passing options to getToken #11917

@Philzen

Description

@Philzen

Summary

When using an auth adapter such as Azure , getToken takes an option argument:

https://github.com/redwoodjs/redwood/blob/231e1f9da81c1d779000397895b2636430742821/packages/auth-providers/azureActiveDirectory/web/src/azureActiveDirectory.ts#L40-L44

Clerk also takes in an options argument for getToken.

However, the current AuthContextInterface implementation does not support this on getToken (while many other methods in this interface allow arguments that are typed via generics):

https://github.com/redwoodjs/redwood/blob/231e1f9da81c1d779000397895b2636430742821/packages/auth/src/AuthContext.ts#L54

Motivation

The current type will therefore lead to a typescript error when trying to use the (existing) argument (i.e. in Azure):

Image

Detailed proposal

Add another generic TGetTokenOptions here:

https://github.com/redwoodjs/redwood/blob/231e1f9da81c1d779000397895b2636430742821/packages/auth/src/AuthContext.ts#L7-L20

and change the getToken type to:

  getToken(options?: TGetTokenOptions): Promise<null | string>

Are you interested in working on this?

  • I'm interested in working on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions