@@ -84,7 +84,7 @@ function* getUsersByHandles(handles) {
84
84
return [ ] ;
85
85
}
86
86
// use 'OR' to link the handle matches
87
- const query = _ . map ( handles , ( h ) => 'handle:"' + h . trim ( ) . replace ( '"' , '\\"' ) + '"' ) . join ( ' OR ' ) ;
87
+ const query = _ . map ( handles , ( h ) => 'handle:"' + h . trim ( ) . replace ( '"' , '\\"' ) + '"' ) . join ( ' OR ' ) ;
88
88
return yield searchUsersByQuery ( query ) ;
89
89
}
90
90
@@ -188,10 +188,20 @@ function* notifyUserViaEmail(user, message) {
188
188
* @returns {Object } the challenge details
189
189
*/
190
190
function * getChallenge ( challengeId ) {
191
- // this is public API, M2M token is not needed
191
+ const token = yield getM2MToken ( ) ;
192
+ // this is public API, but some challege is not accessable so using m2m token
192
193
const url = `${ config . TC_API_V4_BASE_URL } /challenges/${ challengeId } ` ;
193
194
logger . info ( `calling public challenge api ${ url } ` ) ;
194
- const res = yield request . get ( url ) ;
195
+ const res = yield request
196
+ . get ( url )
197
+ . set ( 'Authorization' , `Bearer ${ token } ` )
198
+ . catch ( ( err ) => {
199
+ const errorDetails = _ . get ( err , 'message' ) ;
200
+ throw new Error (
201
+ `Error in call public challenge api by id ${ challengeId } ` +
202
+ ( errorDetails ? ' Server response: ' + errorDetails : '' )
203
+ ) ;
204
+ } ) ;
195
205
if ( ! _ . get ( res , 'body.result.success' ) ) {
196
206
throw new Error ( `Failed to get challenge by id ${ challengeId } ` ) ;
197
207
}
0 commit comments