freeCodeCamp / open-api

freeCodeCamp's open-api Intiative
BSD 3-Clause "New" or "Revised" License
88 stars 28 forks source link

yarn generate-auth-header not working #182

Closed rivera1294 closed 6 years ago

rivera1294 commented 6 years ago

Describe the bug

When running yarn generate-auth-header, an error is returned.

To Reproduce

yarn generate-auth-header
yarn run v1.7.0
$ node scripts/generateHeader
buffer.js:202
  throw new TypeError(kFromErrorMsg);
  ^

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
    at Function.Buffer.from (buffer.js:202:9)
    at Object.<anonymous> (/Users/jasonrivera/open-source/open-api/scripts/generateHeader.js:5:25)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about thiscommand.

Expected behavior

When running this command a valid authorization header should be generated.

Additional context

https://github.com/freeCodeCamp/open-api/blob/9c5bb2207eecea8d69170bd9003c121eec5959e8/scripts/generateHeader.js#L4

If we change this line to

const jwtEncoded = secrets.getSecret().JWT_CERT;

then I can generate an auth header.

Happy to submit a pull request if above approach is correct.

ojongerius commented 6 years ago

@rivera1294 that would be great!

ojongerius commented 6 years ago

Thanks for correcting my mistake 🤦‍♂️ @rivera1294 ! 🎉

rivera1294 commented 6 years ago

Glad I could help @ojongerius!