From 0d42dd66555857440249e56b8ce3d74ff3a693c5 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Mon, 16 Nov 2020 14:55:05 +0200 Subject: [PATCH] Authorize GitHub requests with header instead of query parameter --- .../src/browser/che-github-main.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/extensions/eclipse-che-theia-plugin-ext/src/browser/che-github-main.ts b/extensions/eclipse-che-theia-plugin-ext/src/browser/che-github-main.ts index 1cbc3e5a3..383497122 100644 --- a/extensions/eclipse-che-theia-plugin-ext/src/browser/che-github-main.ts +++ b/extensions/eclipse-che-theia-plugin-ext/src/browser/che-github-main.ts @@ -26,10 +26,14 @@ export class CheGithubMainImpl implements CheGithubMain { async $uploadPublicSshKey(publicKey: string): Promise { 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 { @@ -47,7 +51,9 @@ export class CheGithubMainImpl implements CheGithubMain { } private async getUser(): Promise { - const result = await this.axiosInstance.get('https://api.github.com/user?access_token=' + this.token); + const result = await this.axiosInstance.get('https://api.github.com/user', { + headers: { Authorization: `Bearer ${this.token}` }, + }); return result.data; }