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

fix: OAuth API #96

Merged
merged 5 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions src/rest/remote-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export interface IRemoteAPI {
/**
* Return list of registered oAuth providers.
*/
getOAuthProviders(): Promise<string[]>;
getOAuthProviders(): Promise<{ name: string, endpointUrl: string }[]>;
olexii4 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Updates workspace activity timestamp to prevent stop by timeout when workspace is running and using.
*
Expand Down Expand Up @@ -422,12 +422,15 @@ export class RemoteAPI implements IRemoteAPI {
});
}

getOAuthProviders(): Promise<string[]> {
return new Promise<string[]>((resolve, reject) => {
getOAuthProviders(): Promise<{ name: string, endpointUrl: string }[]> {
return new Promise<{ name: string, endpointUrl: string }[]>((resolve, reject) => {
this.remoteAPI
.getOAuthProviders()
.then((response: AxiosResponse<any[]>) => {
resolve(response.data.map(provider => provider.name));
resolve(response.data.map(provider => {
const { name, endpointUrl } = provider;
return { name, endpointUrl}
}));
})
.catch((error: AxiosError) => {
reject(new RequestError(error));
Expand Down
6 changes: 3 additions & 3 deletions src/rest/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface IResources {
getSshKey<T>(service: string, name: string): AxiosPromise<T>;
getAllSshKey<T>(service: string): AxiosPromise<T[]>;
deleteSshKey(service: string, name: string): AxiosPromise<void>;
getOAuthProviders(): AxiosPromise<any[]>;
getOAuthProviders(): AxiosPromise<{ name: string, endpointUrl: string }[]>;
getOAuthToken(oAuthProvider: string): AxiosPromise<{ token: string }>;
deleteOAuthToken(oAuthProvider: string): AxiosPromise<void>;
getCurrentUser(): AxiosPromise<User>;
Expand Down Expand Up @@ -259,8 +259,8 @@ export class Resources implements IResources {
});
}

public getOAuthProviders(): AxiosPromise<any[]> {
return this.axios.request<any[]>({
public getOAuthProviders(): AxiosPromise<{ name: string, endpointUrl: string }[]> {
return this.axios.request<{ name: string, endpointUrl: string }[]>({
method: 'GET',
baseURL: this.baseUrl,
url: '/oauth',
Expand Down