@@ -442,15 +442,15 @@ methods.convertAuthIntoDynamicValue = (auth) => {
442
442
* @param {Environment } environment: the environment in which this auth value is applicable.
443
443
* @param {Auth } auth: the auth to add to the domain
444
444
* @param {string } key: the name of the auth
445
- * @returns {EnvironmentVariable } the newly created environment variable.
445
+ * @returns {{ variable: EnvironmentVariable, auth: Auth } } the newly created environment variable.
446
446
*/
447
447
methods . addAuthToDomain = ( domain , environment , auth , key ) => {
448
448
const variable = domain . createEnvironmentVariable ( key )
449
449
const dv = methods . convertAuthIntoDynamicValue ( auth )
450
450
const ds = methods . wrapDV ( dv )
451
451
variable . setValue ( ds , environment )
452
452
453
- return variable
453
+ return { variable, auth }
454
454
}
455
455
456
456
/**
@@ -1041,26 +1041,33 @@ methods.convertAuthFromReference = (store, reference) => {
1041
1041
* converts a reference or an auth into a DynamicString Entry.
1042
1042
* @param {Store } store: the store used to resolve references
1043
1043
* @param {Auth|Reference } authOrReference: the record to convert into a DynamicString
1044
- * @returns {DynamicString } the corresponding DynamicString
1044
+ * @returns {{ variable: DynamicString, auth: Auth } } the corresponding DynamicString
1045
1045
*/
1046
1046
methods . convertReferenceOrAuthToDsEntry = ( store , authOrReference ) => {
1047
1047
if ( authOrReference instanceof Reference ) {
1048
1048
return methods . convertAuthFromReference ( store , authOrReference )
1049
1049
}
1050
1050
1051
1051
const dv = methods . convertAuthIntoDynamicValue ( authOrReference )
1052
- return methods . wrapDV ( dv )
1052
+ return { variable : methods . wrapDV ( dv ) , auth : authOrReference }
1053
1053
}
1054
1054
1055
1055
// TODO create Variable DS that has enum with all auth possible
1056
1056
/**
1057
1057
* sets the Auth DynamicString as am Authorization Header.
1058
1058
* @param {PawRequest } pawRequest: the paw request to update
1059
- * @param {DynamicString } auth: the DynamicString representing an auth
1059
+ * @param {Objecti } authData: the object containing the auth representation as a DynamicString and
1060
+ * the original auth Record.
1061
+ * @param {DynamicString } variable: the DynamicString representing an auth
1062
+ * @param {Auth } auth: the original auth
1060
1063
* @returns {PawRequest } the update paw request
1061
1064
*/
1062
- methods . addAuthToRequest = ( pawRequest , auth ) => {
1063
- pawRequest . setHeader ( 'Authorization' , auth )
1065
+ methods . addAuthToRequest = ( pawRequest , { variable, auth } ) => {
1066
+ let authName = 'Authorization'
1067
+ if ( auth instanceof Auth . ApiKey ) {
1068
+ authName = auth . get ( 'name' )
1069
+ }
1070
+ pawRequest . setHeader ( authName , variable )
1064
1071
return pawRequest
1065
1072
}
1066
1073
0 commit comments