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 #939

Merged
merged 1 commit into from
Nov 27, 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 @@ -24,10 +24,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 @@ -44,7 +48,9 @@ export class CheGithubMainImpl implements CheGithubMain {
await this.updateToken();
} else {
try {
await this.axiosInstance.get('https://api.github.com/user?access_token=' + this.token);
await this.axiosInstance.get('https://api.github.com/user', {
headers: { Authorization: `Bearer ${this.token}` },
});
} catch (e) {
await this.updateToken();
}
Expand Down