mirror of
https://github.com/int128/kubelogin.git
synced 2026-05-21 07:12:47 +00:00
* Split oidc/client.go * Refactor * Fix * Improve comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
19 lines
516 B
Go
19 lines
516 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/int128/kubelogin/pkg/oidc"
|
|
)
|
|
|
|
// GetTokenByROPC performs the resource owner password credentials flow.
|
|
func (c *client) GetTokenByROPC(ctx context.Context, username, password string) (*oidc.TokenSet, error) {
|
|
ctx = c.wrapContext(ctx)
|
|
token, err := c.oauth2Config.PasswordCredentialsToken(ctx, username, password)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("resource owner password credentials flow error: %w", err)
|
|
}
|
|
return c.verifyToken(ctx, token, "")
|
|
}
|