Files
plane/web/ee/silo/integrations/github/services/auth.service.ts
sriram veeraghanta 00463d948a silo: redirect url fixes (#2068)
* fix: oauth redirect urls

* fix: silo base path hardcode

* fix: transform batch count on job completion

* fix: callback uri for asana

* fix: build errors

---------

Co-authored-by: Saurabhkmr98 <saurabhkapur73@gmail.com>
Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
2025-01-02 14:32:29 +05:30

42 lines
1.2 KiB
TypeScript

import axios, { AxiosInstance } from "axios";
import { GithubAuthorizeState } from "@plane/etl/github";
import { SILO_BASE_PATH } from "@plane/constants";
export class IntegrationAuthService {
protected baseURL: string;
private axiosInstance: AxiosInstance;
constructor(baseURL: string) {
this.baseURL = baseURL;
this.axiosInstance = axios.create({ baseURL });
}
/**
* @description authenticate the github organization
* @param { GithubAuthorizeState } payload
* @redirects to the Github authentication URL
*/
async githubOrganizationAuthentication(payload: GithubAuthorizeState) {
return this.axiosInstance
.post(`${SILO_BASE_PATH}/api/github/auth/url`, payload)
.then((res) => res.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* @description authenticate the github personal account
* @param { GithubAuthorizeState } payload
* @redirects to the Github authentication URL
*/
async githubPersonalAccountAuthentication(payload: GithubAuthorizeState) {
return this.axiosInstance
.post(`${SILO_BASE_PATH}/api/github/auth/user/url`, payload)
.then((res) => res.data)
.catch((error) => {
throw error?.response?.data;
});
}
}