Skip to content

Commit

Permalink
build: add typings for additional query params for auth (#1534)
Browse files Browse the repository at this point in the history
* build: initial implementation of additional query params for auth

---------

Co-authored-by: Daniel Bankhead <danielbankhead@google.com>
  • Loading branch information
sofisl and danielbankhead authored Apr 4, 2023
1 parent f4d9335 commit be252f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ export interface GenerateAuthUrlOpts {
* must be used with the 'code_challenge' parameter described above.
*/
code_challenge?: string;

/**
* A way for developers and/or the auth team to provide a set of key value
* pairs to be added as query parameters to the authorization url.
*/
[
key: string
]: querystring.ParsedUrlQueryInput[keyof querystring.ParsedUrlQueryInput];
}

export interface AccessTokenResponse {
Expand Down
4 changes: 4 additions & 0 deletions test/test.oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ describe('oauth2', () => {
access_type: ACCESS_TYPE,
scope: SCOPE,
response_type: 'code token',
random: 'thing',
another: 'random_thing',
};

const oauth2client = new OAuth2Client({
Expand All @@ -89,6 +91,8 @@ describe('oauth2', () => {
assert.strictEqual(query.get('scope'), SCOPE);
assert.strictEqual(query.get('client_id'), CLIENT_ID);
assert.strictEqual(query.get('redirect_uri'), REDIRECT_URI);
assert.strictEqual(query.get('random'), 'thing');
assert.strictEqual(query.get('another'), 'random_thing');
done();
});

Expand Down

0 comments on commit be252f5

Please sign in to comment.