5
5
IHttpRequestMethods ,
6
6
IDataObject ,
7
7
} from 'n8n-workflow' ;
8
- import { base64Decode , base64Encode } from './base64Utils' ;
8
+ import { base64Decode } from './base64Utils' ;
9
9
10
10
export const DEFAULT_API_HOST = 'https://cloud.yepcode.io' ;
11
11
@@ -21,19 +21,19 @@ export async function getYepCodeCredentials(
21
21
} ;
22
22
}
23
23
24
- export async function obtainAccessToken (
24
+ async function obtainAccessToken (
25
25
this : IExecuteFunctions | ILoadOptionsFunctions ,
26
26
apiHost : string ,
27
- clientId : string ,
28
- clientSecret : string ,
27
+ teamId : string ,
28
+ apiToken : string ,
29
29
) : Promise < string > {
30
30
try {
31
31
const options : IHttpRequestOptions = {
32
32
method : 'POST' ,
33
- url : `${ apiHost } /auth/realms/yepcode/protocol/openid-connect /token` ,
33
+ url : `${ apiHost } /api/ ${ teamId } /rest/auth /token` ,
34
34
headers : {
35
35
'Content-Type' : 'application/x-www-form-urlencoded' ,
36
- authorization : `Basic ${ base64Encode ( ` ${ clientId } : ${ clientSecret } ` ) } ` ,
36
+ 'x-api-token' : apiToken ,
37
37
} ,
38
38
body : 'grant_type=client_credentials' ,
39
39
} ;
@@ -82,7 +82,7 @@ export async function apiRequest(
82
82
throw new Error ( 'Invalid clientId format: ' + clientId ) ;
83
83
}
84
84
85
- const accessToken = await obtainAccessToken . call ( this , apiHost , clientId , clientSecret ) ;
85
+ const accessToken = await obtainAccessToken . call ( this , apiHost , teamId , apiToken ) ;
86
86
const options : IHttpRequestOptions = {
87
87
method,
88
88
url : `${ apiHost } /api/${ teamId } /rest/${ endpoint } ` ,
0 commit comments