@@ -84,7 +84,7 @@ function* getUsersByHandles(handles) {
8484 return [ ] ;
8585 }
8686 // 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 ' ) ;
8888 return yield searchUsersByQuery ( query ) ;
8989}
9090
@@ -188,10 +188,20 @@ function* notifyUserViaEmail(user, message) {
188188 * @returns {Object } the challenge details
189189 */
190190function * 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
192193 const url = `${ config . TC_API_V4_BASE_URL } /challenges/${ challengeId } ` ;
193194 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+ } ) ;
195205 if ( ! _ . get ( res , 'body.result.success' ) ) {
196206 throw new Error ( `Failed to get challenge by id ${ challengeId } ` ) ;
197207 }
0 commit comments