PromucFlow_constructor/app/client/src/api/OAuthApi.ts
Favour Ohanekwu 72f8b7e2e1
feat: Support OAuth for all plugin types (#9657)
* customize datasource authorization

* improve performance

* fix save datasource bug

* switch auth type from form config

* better naming of components

* fix minor bug

* minor bug fix

* minor bug fix

* syntax cleanup

* Add comments where necessary

* Added comments where necessary

* fix broken airtable page

* code refactor and annotation
2022-01-14 12:01:54 +05:30

29 lines
802 B
TypeScript

import Api from "./Api";
import { AxiosPromise } from "axios";
import { GenericApiResponse } from "api/ApiResponses";
import { Datasource } from "entities/Datasource";
class OAuthApi extends Api {
static url = "v1/saas";
// Api endpoint to get "Appsmith token" from server
static getAppsmithToken(
datasourceId: string,
pageId: string,
): AxiosPromise<GenericApiResponse<string>> {
return Api.post(`${OAuthApi.url}/${datasourceId}/pages/${pageId}/oauth`);
}
// Api endpoint to get access token for datasource authorization
static getAccessToken(
datasourceId: string,
token: string,
): AxiosPromise<GenericApiResponse<Datasource>> {
return Api.post(
`${OAuthApi.url}/${datasourceId}/token?appsmithToken=${token}`,
);
}
}
export default OAuthApi;