Create authentication with oAuth using a third-party vendor. Currently, only GitHub is available, but more will be added in the future.
17 lines
506 B
TypeScript
17 lines
506 B
TypeScript
import * as arctic from "arctic";
|
|
import { githubProvider } from "../providers/github.provider";
|
|
import { AppError } from "../../../helpers/error/instances/app";
|
|
|
|
export const githubRequestService = async () => {
|
|
try {
|
|
const github = githubProvider();
|
|
const state = arctic.generateState();
|
|
const scopes = ["user:email"];
|
|
const url = github.createAuthorizationURL(state, scopes);
|
|
|
|
return url;
|
|
} catch (error) {
|
|
throw new AppError(500, "Oops! something happening", error);
|
|
}
|
|
};
|