diff --git a/API.md b/API.md index a45e989..c4b0103 100644 --- a/API.md +++ b/API.md @@ -332,7 +332,10 @@ signIn( authorizationCode?: string, sessionState?: string, authState?: string, - callback?: (response: BasicUserInfo) => void + callback?: (response: BasicUserInfo) => void, + tokenRequestConfig?: { + params: Record + } ); ``` @@ -348,6 +351,15 @@ signIn( The `signIn` method can be passed the state parameter as an argument, which will be used to obtain the token during the token-request phase of the method. 5. **callback?**: (response: [`BasicUserInfo`](#basicuserinfo)) => `void` A callback function that fires when sign-in is successful. The callback function takes an object of type [`BasicUserInfo`](#basicuserinfo) as an argument. +6. **tokenRequestConfig?**: `object` (optional) + An optional configuration object that allows you to augment the token request. + - `params` (Mandatory): Key-value pairs to be sent as additional parameters in the token request payload. + + ```TypeScript + tokenRequestConfig: { + params: Record + } + ``` The `sign-in` hook is used to fire a callback function after signing out is successful. Check the [`on()`](#on) section for more information. #### Example diff --git a/lib/package.json b/lib/package.json index 9a4c6e0..6a4f2a0 100755 --- a/lib/package.json +++ b/lib/package.json @@ -37,7 +37,7 @@ "author": "WSO2", "license": "Apache-2.0", "dependencies": { - "@asgardeo/auth-spa": "^3.0.7" + "@asgardeo/auth-spa": "^3.1.0" }, "devDependencies": { "@babel/cli": "^7.19.3", diff --git a/lib/src/api.ts b/lib/src/api.ts index 1682bcd..c0c35d4 100644 --- a/lib/src/api.ts +++ b/lib/src/api.ts @@ -81,10 +81,13 @@ class AuthAPI { authorizationCode: string, sessionState: string, authState?: string, - callback?: (response: BasicUserInfo) => void + callback?: (response: BasicUserInfo) => void, + tokenRequestConfig?: { + params: Record + } ): Promise { return this._client - .signIn(config, authorizationCode, sessionState, authState) + .signIn(config, authorizationCode, sessionState, authState, tokenRequestConfig) .then(async (response: BasicUserInfo) => { if (!response) { return; diff --git a/lib/src/authenticate.tsx b/lib/src/authenticate.tsx index cec5164..8f10ec7 100644 --- a/lib/src/authenticate.tsx +++ b/lib/src/authenticate.tsx @@ -85,7 +85,10 @@ const AuthProvider: FunctionComponent void + callback?: (response: BasicUserInfo) => void, + tokenRequestConfig?: { + params: Record + } ): Promise => { try { setError(null); @@ -96,7 +99,8 @@ const AuthProvider: FunctionComponent void + callback?: (response: BasicUserInfo) => void, + tokenRequestConfig?: { + params: Record + } ) => Promise; signOut: (callback?: (response: boolean) => void) => Promise; getBasicUserInfo(): Promise;