title: Validating signature of JWT in Azure AD B2C with NodeJS
body: <p>I'm following <a href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-oidc" rel="nofollow noreferrer">this article</a> to implement Azure B2C in our Node.JS app.
  I got back JWT token and trying to validate signature.
  Using jsonwebtoken npm module to verify my token.
  Also, I got public keys from the OpenID Connect metadata endpoint. They are in JSON and looks like this:</p>
  
  <pre><code>{   "keys": [{
          "kid": "some kid value",
          "nbf": some number,
          "use": "sig",
          "kty": "RSA",
          "e": "AQAB",
          "n": "some long key"
      }, {
          "kid": "some kid value",
          "nbf": some number,
          "use": "sig",
          "kty": "RSA",
          "e": "AQAB",
          "n": "some long key"
      }, {
          "kid": "some kid value",
          "nbf": some number,
          "use": "sig",
          "kty": "RSA",
          "e": "AQAB",
          "n": "some long key"
      }]
  }
  </code></pre>
  
  <p>So when I'm trying to pass 'n' value from appropriate key to the </p>
  
  <pre><code>jwt.verify(token, 'my n value go here',  { algorithms: ['RS256'] }, callbackFunction());
  </code></pre>
  
  <p>I got </p>
  
  <blockquote>
    <p>Error: PEM_read_bio_PUBKEY failed</p>
  </blockquote>
  
  <p>I feel like I'm passing the wrong key, and I could not find any explanation about how I can use this public key metadata to validate tokens.
  The only helpful line from the article:</p>
  
  <blockquote>
    <p>A description of how to perform signature validation is outside the scope of this document. Many open source libraries are available to help you with this if you need it.</p>
  </blockquote>
  
  <p>How do I validate a signature?</p>