Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get base64-encoded token #92

Closed
chr1shung opened this issue May 25, 2022 · 2 comments
Closed

How to get base64-encoded token #92

chr1shung opened this issue May 25, 2022 · 2 comments

Comments

@chr1shung
Copy link

From the sample code:

...

b, err := builder.Build()
if err != nil {
    panic(fmt.Errorf("failed to build biscuit: %v", err))
}
token, err := b.Serialize()
if err != nil {
    panic(fmt.Errorf("failed to serialize biscuit: %v", err))
}

I tried

fmt.Println(string(token))

and

fmt.Println(base64.StdEncoding.EncodeToString(token))

Both output are not accepted by the online token-inspector tool

How do I transform token to a base64-encoded string so that I can share with other easily ?
Thanks for the help

@chilarai
Copy link
Contributor

chilarai commented Mar 9, 2023

Instead of base64.StdEncoding, use base64.URLEncoding which should make the final command look like

fmt.Println(base64.URLEncoding.EncodeToString(token))

This made it work

@Geal
Copy link
Contributor

Geal commented Mar 9, 2023

yes, we generally use URL safe base64 encoding. I'm opening biscuit-auth/biscuit#128 to emphasize it

@Geal Geal closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants