https://github.com/akshaybabloo/pkce
Generate PKCE verify and challenge code
https://github.com/akshaybabloo/pkce
go pkce pkce-flow
Last synced: 6 months ago
JSON representation
Generate PKCE verify and challenge code
- Host: GitHub
- URL: https://github.com/akshaybabloo/pkce
- Owner: akshaybabloo
- License: mit
- Created: 2021-03-05T02:22:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T10:38:49.000Z (over 1 year ago)
- Last Synced: 2025-04-13T21:17:30.115Z (6 months ago)
- Topics: go, pkce, pkce-flow
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Proof Key for Code Exchange (PKCE)
[](https://github.com/akshaybabloo/pkce/actions/workflows/go.yml)
[](https://pkg.go.dev/github.com/akshaybabloo/pkce)
[](https://codecov.io/gh/akshaybabloo/pkce)Generate PKCE verify and challenge code.
## Instillation
```shell
go get github.com/akshaybabloo/pkce/v2
```## Usage
There are two ways of doing this
### Your own string
You can put in your own string, example:
```go
package mainimport (
"fmt""github.com/akshaybabloo/pkce/v2"
)func main() {
p := pkce.Pkce{
RandomString: "45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914",
}fmt.Println(p.VerifyCode()) // This is optional
// Output: 45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914
fmt.Println(p.ChallengeCode())
// Output: iQoF8w9kq5RnuMdisRXypyOoMCF7FGz-ro7dwHjC28U
}
```When you enter your own string, calling `p.VerifyCode()` is optional
### Let us generate one for you
You can let the module generate a random string for you, but the length should be more than or equal to `43` and lest and or equal to `128`.
```go
package mainimport (
"fmt""github.com/akshaybabloo/pkce/v2"
)func main() {
p := pkce.Pkce{
Length: 128,
}fmt.Println(p.VerifyCode()) // This is optional
// Output: 45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914
fmt.Println(p.ChallengeCode())
// Output: iQoF8w9kq5RnuMdisRXypyOoMCF7FGz-ro7dwHjC28U
}
```> Note: Calling `p.VerifyCode()` optional, but calling it after `p.ChallengeCode()` will reset `pkce.RandomString`