fix: Move request helper function (#2594)

* Move request method to passport utils

* Use request method in OIDC provider
This commit is contained in:
Saumya Pandey
2021-09-29 19:50:05 +05:30
committed by GitHub
parent 78464f315c
commit 0ed7286fc6
3 changed files with 17 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
// @flow
import { addMinutes, subMinutes } from "date-fns";
import fetch from "fetch-with-proxy";
import { type Request } from "koa";
import { OAuthStateMismatchError } from "../errors";
import { getCookieDomain } from "./domains";
@@ -47,3 +48,15 @@ export class StateStore {
callback(null, true);
};
}
export async function request(endpoint: string, accessToken: string) {
const response = await fetch(endpoint, {
method: "GET",
credentials: "same-origin",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
});
return response.json();
}