Skip to content

Commit

Permalink
chore:add optional parameter to auth (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVarchuk authored Sep 15, 2021
1 parent 128aea9 commit f68ff65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/redocly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class RedoclyClient {

async verifyToken(accessToken: string, verbose: boolean = false): Promise<boolean> {
if (!accessToken) return false;
const authDetails = await RedoclyClient.authorize(accessToken, verbose);
const authDetails = await RedoclyClient.authorize(accessToken, { verbose });
if (!authDetails) return false;
return true;
}
Expand Down Expand Up @@ -91,9 +91,10 @@ export class RedoclyClient {
});
}

static async authorize(accessToken: string, verbose: boolean = false) {
static async authorize(accessToken: string, options: { queryName?: string; verbose?: boolean }) {
const { queryName = '', verbose = false } = options;
try {
const queryStr = `{ viewer { id } }`;
const queryStr = `query ${queryName}{ viewer { id } }`;

return await query(queryStr, {}, { Authorization: accessToken });
} catch (e) {
Expand Down

0 comments on commit f68ff65

Please sign in to comment.