Generate PKCE verify and challenge code.
go get github.com/akshaybabloo/pkce/v2
There are two ways of doing this
You can put in your own string, example:
package main
import (
"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
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
.
package main
import (
"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 afterp.ChallengeCode()
will resetpkce.RandomString