Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:add optional parameter to auth #368

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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