mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
[simple-oauth2] fix: allow custom fields (#40797)
* fix: allow custom fields * test: add test
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
a1708a1b80
commit
0d12531ffe
Vendored
+6
@@ -72,6 +72,8 @@ export interface AccessToken {
|
||||
|
||||
export type AuthorizationCode = string;
|
||||
export interface AuthorizationTokenConfig {
|
||||
[key: string]: any;
|
||||
|
||||
/** Authorization code (from previous step) */
|
||||
code: AuthorizationCode;
|
||||
/** A string that represents the callback uri */
|
||||
@@ -81,6 +83,8 @@ export interface AuthorizationTokenConfig {
|
||||
}
|
||||
|
||||
export interface PasswordTokenConfig {
|
||||
[key: string]: any;
|
||||
|
||||
/** A string that represents the registered username */
|
||||
username: string;
|
||||
/** A string that represents the registered password. */
|
||||
@@ -90,6 +94,8 @@ export interface PasswordTokenConfig {
|
||||
}
|
||||
|
||||
export interface ClientCredentialTokenConfig {
|
||||
[key: string]: any;
|
||||
|
||||
/** A string that represents the application privileges */
|
||||
scope?: string | string[];
|
||||
}
|
||||
|
||||
@@ -143,3 +143,21 @@ const oauth2 = oauth2lib.create(credentials);
|
||||
|
||||
// // => { "status": "401", "message": "Unauthorized" }
|
||||
// })();
|
||||
|
||||
// #Custom Grant
|
||||
(async () => {
|
||||
const tokenConfig = {
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
scope: [ '<scope1>', '<scope2>' ],
|
||||
grant_type: 'openapi_2lo'
|
||||
};
|
||||
|
||||
// Save the access token
|
||||
try {
|
||||
const result = await oauth2.ownerPassword.getToken(tokenConfig);
|
||||
const accessToken = oauth2.accessToken.create(result);
|
||||
} catch (error) {
|
||||
console.log('Access Token Error', error.message);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user