Skip to content

Instantly share code, notes, and snippets.

@tonyxu-io
Last active April 20, 2023 20:19
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save tonyxu-io/21eb57ab2a4aeb2a3ee10f77542abe64 to your computer and use it in GitHub Desktop.
Save tonyxu-io/21eb57ab2a4aeb2a3ee10f77542abe64 to your computer and use it in GitHub Desktop.
PKCE Code Verifier and Code Challenge Generator. DEMO:https://tonyxu-io.github.io/pkce-generator/
@antoninbouchal
Copy link

Hi. Great tool. Really helped me.
I just don't know why base64 here is different than other standards I tried.

Just please change length of generated code verifier from 43 to 128.
It is on standard and on WSO2 gateway this was issue and it was really hard to figure out, where is problem.

Thank you.

@tonyxu-io
Copy link
Author

Hi. Great tool. Really helped me.
I just don't know why base64 here is different than other standards I tried.

Just please change length of generated code verifier from 43 to 128.
It is on standard and on WSO2 gateway this was issue and it was really hard to figure out, where is problem.

Thank you.

Hi, thanks for pointing this issue out. I just updated the length to 128. It should be good now.

@FolabiAhn
Copy link

Great tool, really. Helps me a lot

@leonvisscher
Copy link

According to the same standard @antoninbouchal mentioned, possible characters also contain "-" / "." / "_" / "~"

@tonyxu-io
Copy link
Author

According to the same standard @antoninbouchal mentioned, possible characters also contain "-" / "." / "_" / "~"

You are right, thanks for pointing out. I fixed with those characters.

@anderspitman
Copy link

anderspitman commented May 23, 2020

Note than Math.random is not cryptographically secure, so you really shouldn't use it for this purpose. I recommend using the code here instead: https://github.com/aaronpk/pkce-vanilla-js

It has the added bonus on not having any dependencies, ie you don't need CryptoJS.

The author is a big name in the OAuth2 community.

@bilelz
Copy link

bilelz commented Apr 30, 2021

Thanks for sharing
I writed another PKCE generator without external libs (vanilla js) https://gist.github.com/bilelz/4449430eb1070fc34b8ebfaf5fb9f9b5

@tonyxu-io
Copy link
Author

Thank you all for sharing vanilla JS version without external libraries. I created this demo mainly to demonstrate the functions required to generate the challenge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment