Skip to content

Instantly share code, notes, and snippets.

@jongio
Created August 7, 2020 01:11
Show Gist options
  • Save jongio/b52d128c51eb2a55d45ce50e7d3b3fa9 to your computer and use it in GitHub Desktop.
Save jongio/b52d128c51eb2a55d45ce50e7d3b3fa9 to your computer and use it in GitHub Desktop.
class MyTokenCredential implements coreHttp.TokenCredential {
public token: string;
public expiresOn: number;
constructor(token: string, expiresOn?: Date) {
this.token = token;
this.expiresOn = expiresOn
? expiresOn.getTime()
: Date.now() + 60 * 60 * 1000;
}
async getToken(
_scopes: string | string[],
_options?: coreHttp.GetTokenOptions
): Promise<coreHttp.AccessToken | null> {
return {
token: this.token,
expiresOnTimestamp: this.expiresOn
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment