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

How to add state in auth url #188

Closed
haanamomo opened this issue Sep 9, 2019 · 6 comments
Closed

How to add state in auth url #188

haanamomo opened this issue Sep 9, 2019 · 6 comments

Comments

@haanamomo
Copy link

I find that theauthorizationUrl method would take the following parameter

export interface AuthorizationUrlParameters {
    readonly redirect_uri?: string;
    readonly response_type?: string;
    readonly scope?: string;

    readonly response_mode?: string;
    readonly nonce?: string;
    readonly resource?: string;
    readonly code_challenge?: string;
    readonly code_challenge_method?: string;
}

I cannot find a place to pass state to create the auth url, so now I just append state to the string

client.authorizationUrl({
            scope: 'openid',
            code_challenge: codeChallenge,
            code_challenge_method: 'S256',
          }) + '&state=testtestme'

Is there a right way to pass state?

@panva
Copy link
Owner

panva commented Sep 9, 2019

You should read docs rather than incomplete unofficial typings

https://github.com/panva/node-openid-client/blob/master/docs/README.md#clientauthorizationurlparameters

any other authorization parameters may be provided

@panva panva closed this as completed Sep 9, 2019
@haanamomo
Copy link
Author

Find the right way to pass in state:

client.authorizationUrl({
            scope: 'openid',
            code_challenge: codeChallenge,
            code_challenge_method: 'S256',
            state: 'testtestme',
          } as any)

@panva
Copy link
Owner

panva commented Sep 9, 2019

That is not the right way with the upcoming official types being developed in #184, you don't need to pass as any in those since AuthorizationParameters not only enumerates all known to me today but also [key: string]: unknown; making you able to pass in any parameter the way you should according to the official documentation.

@haanamomo
Copy link
Author

The version I use is "@types/openid-client": "^3.1.6".
There is no [key: string]: unknown in AuthorizationParameters interface

@panva
Copy link
Owner

panva commented Sep 9, 2019

I reiterate, once more, @types/openid-client is not official and any issues you have with it should be directed at its authors.

Once #184 lands openid-client will bundle its own types and I will ask the authors of the incomplete types to retire it.

@haanamomo
Copy link
Author

OK, I understand now, when the official type of openid-client releases, I will change the code. Thanks for reply!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants