mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
✨ Github OAuth support
This commit is contained in:
@@ -17,17 +17,24 @@ import {
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('githubApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
const githubApiCredentials = this.getCredentials('githubApi');
|
||||
const oAuth2ApiCrendetials = this.getCredentials('oAuth2Api');
|
||||
let headers = {}
|
||||
if (githubApiCredentials !== undefined) {
|
||||
headers = {
|
||||
Authorization: `token ${githubApiCredentials.accessToken}`,
|
||||
'User-Agent': githubApiCredentials.user,
|
||||
};
|
||||
} else {
|
||||
const { access_token } = oAuth2ApiCrendetials!.oauthTokenData as IDataObject;
|
||||
headers = {
|
||||
Authorization: `token ${access_token}`,
|
||||
'User-Agent': 'Node js',
|
||||
};
|
||||
}
|
||||
|
||||
const options = {
|
||||
method,
|
||||
headers: {
|
||||
'Authorization': `token ${credentials.accessToken}`,
|
||||
'User-Agent': credentials.user,
|
||||
},
|
||||
headers,
|
||||
body,
|
||||
qs: query,
|
||||
uri: `https://api.github.com${endpoint}`,
|
||||
|
||||
Reference in New Issue
Block a user