-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow the client to accept an oauth2.TokenSource #212
Comments
Personal Access Token example // PATTokenSource ...
type PATTokenSource struct {
PAT string
}
// Duration100Years ...
const Duration100Years = 100 * 365 * 24 * time.Hour
// Token ...
func (s *PATTokenSource) Token() (*oauth2.Token, error) {
return &oauth2.Token{
AccessToken: s.PAT,
TokenType: "Bearer",
Expiry: time.Now().Add(Duration100Years),
}, nil
}
// PATJWTProfileTokenSource ...
func PATJWTProfileTokenSource(pat string) middleware.JWTProfileTokenSource {
return func(issuer string, scopes []string) (oauth2.TokenSource, error) {
return &PATTokenSource{
PAT: pat,
}, nil
}
}
var options []zitadel.Option
options = append(options , zitadel.WithJWTProfileTokenSource(startup.PATJWTProfileTokenSource(ZitadelPersonalAccessToken)))
options = append(options, zitadel.WithInsecure()) |
Thanks for sharing this. We will work on our go sdk in the coming sprint and I think this will be a super input. CC @hifabienne since I am not sure who will work on this I am going to tag you 😁 |
8 tasks
I just made a reference in the issue for the go sdk/examples |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to use the OAuth2 clientcredentials tokensource when using the SDK.
Its working, but it requires that I coerce JWTProfileTokenSource into doing something that it wasn't meant to do.
The library should only take a oauth2.TokenSource, where JWTProfileTokenSource return an oauth2.TokenSouce.
The same would work for a PAT version (i.e. static token).
The text was updated successfully, but these errors were encountered: