Search code examples
javascriptbase64decoder

Failed to decode base64 in javascript


I receive an id_token as part of my current href. It is encoded in base64. I try to decode it using atob(extractedIdToken), but get the following error:

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded

When I copy and paste the extracted id_token in my code and go to an online decoding site, it decodes correctly. Do you have suggestion?


Solution

  • Thanks all for your answers. I ended up moving the Base64 decoding process to the Java backend using the java package: java.util.Base64.