Skip to content
Snippets Groups Projects
Commit c1c683f1 authored by Christian ZHENG's avatar Christian ZHENG
Browse files

refactor(login): rewrite test class

parent 26839d6c
No related branches found
No related tags found
No related merge requests found
import { log } from 'recorder/utils';
import KeycloakOAuth2DeviceFlowConnection from './keycloakOAuth2DeviceFlowConnection';
/**
* Maybe temporary file ?\
* This class shows how to use KeycloakOAuth2DeviceFlowConnection.\
* It is currently based on dev.deadlock instance\
* but there are only some urls to change for further testings.
*
*/
export default class KeycloakOAuth2DeviceFlowConnectionTest {
public connection: KeycloakOAuth2DeviceFlowConnection;
constructor() {
log(' --- KeycloakOAuth2DeviceFlowConnectionTest --- ');
this.connection = new KeycloakOAuth2DeviceFlowConnection(
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/auth/device',
'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/token',
);
}
public run(): void {}
/**
* Simple working examples
*/
public async run() {
const openLinkPlaceholder = (link: string) => {
log(`click here: ${link}`);
};
let tokens = await this.connection.getToken({ openLink: openLinkPlaceholder });
console.log('tokens', tokens);
if (!tokens?.refreshToken) {
console.log("refresh token doesn't exist");
return;
}
let refreshedTokens = await this.connection.getToken({
refreshToken: tokens.refreshToken,
openLink: openLinkPlaceholder,
});
console.log('refreshed tokens', refreshedTokens);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment