Skip to content

Instantly share code, notes, and snippets.

@tonyxu-io
Last active April 20, 2023 20:19
Show Gist options
  • 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/
@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