Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Authorize GitHub requests with header instead of query parameter #924

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ export class CheGithubMainImpl implements CheGithubMain {

async $uploadPublicSshKey(publicKey: string): Promise<void> {
await this.fetchToken();
await this.axiosInstance.post('https://api.github.com/user/keys?access_token=' + this.token, {
title: 'che-theia',
key: publicKey,
});
await this.axiosInstance.post(
'https://api.github.com/user/keys',
{
title: 'che-theia',
key: publicKey,
},
{ headers: { Authorization: `Bearer ${this.token}` } }
);
}

async $getToken(): Promise<string> {
Expand All @@ -47,7 +51,9 @@ export class CheGithubMainImpl implements CheGithubMain {
}

private async getUser(): Promise<GithubUser> {
const result = await this.axiosInstance.get<GithubUser>('https://api.github.com/user?access_token=' + this.token);
const result = await this.axiosInstance.get<GithubUser>('https://api.github.com/user', {
headers: { Authorization: `Bearer ${this.token}` },
});
return result.data;
}

Expand Down