Skip to content

Commit

Permalink
docs(readme): add v3 refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
antokara committed Jan 9, 2020
1 parent 4dfc00a commit d40baaf
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ const v2Callback = token => {
}
};

const v3Callback = token => {
const v3Callback = (token, refreshToken) => {
if (typeof token === 'string') {
console.log('this is the token', token);
if (typeof refreshToken === 'function') {
console.log('this is the refresh token function', refreshToken);
}
} else {
console.log('token retrieval in progress...');
}
Expand Down Expand Up @@ -129,9 +132,15 @@ const v2Callback: TReCaptchaV2Callback = (
}
};

const v3Callback: TReCaptchaV3Callback = (token: string | void): void => {
const v3Callback: TReCaptchaV3Callback = (
token: string | void,
refreshToken: TReCaptchaV3RefreshToken | void
): void => {
if (typeof token === 'string') {
console.log('this is the token', token);
if (typeof refreshToken === 'function') {
console.log('this is the refresh token function', refreshToken);
}
} else {
console.log('token retrieval in progress...');
}
Expand Down Expand Up @@ -198,10 +207,10 @@ The use of this component is not required but can be combined with the v2 reCAPT

#### ReCaptchaV3 Props

| prop | type | default value | description |
| -------- | ------------------------------ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| callback | function(token:string or void) | n/a | Required. When called without arguments, it means requesting token in progress. When called with string (token), it means token retrieved |
| action | string | n/a | Required. The name of the action to keep score and statistic about. It can only contain alphanumeric characters and slashes, and must not be user-specific |
| prop | type | default value | description |
| -------- | ------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| callback | function(token:string or void, refreshToken:fn or void) | n/a | Required. When called without arguments, it means requesting token in progress. When called with string (token) and function (refreshToken), it means token retrieved. The refreshToken function can be used at any time, to refresh the token by calling it |
| action | string | n/a | Required. The name of the action to keep score and statistic about. It can only contain alphanumeric characters and slashes, and must not be user-specific |

## working examples

Expand Down

0 comments on commit d40baaf

Please sign in to comment.