A go library for oidc-agent is available at https://github.com/indigo-dc/liboidcagent-go.
To use it in your go application do
gogetgithub.com/indigo-dc/liboidc-agent-go
and include:
import"github.com/indigo-dc/liboidcagent-go"
Requesting an Access Token
The following functions can be used to obtain an access token for a specific account configuration or for a given OpenID provider from oidc-agent.
Token Request
All functions take a TokenRequest struct. This struct describes the request:
// TokenRequest is used to request an access token from the agenttypeTokenRequeststruct {// ShortName that should be used (Can be omitted if IssuerURL is specified) ShortName string// IssuerURL for which an access token should be obtained (Can be omitted// if ShortName is specified) IssuerURL string// MinValidPeriod specifies how long the access token should be valid at// least. The time is given in seconds. Default is 0. MinValidPeriod uint64// The scopes for the requested access token Scopes []string// The audiences for the requested access token Audiences []string// A string describing the requesting application (i.e. its name). It might// be displayed to the user, if the request must be confirmed or an account// configuration loaded. ApplicationHint string}
This function requests an access token from oidc-agent according to the passed TokenRequest.
Return Value
The function returns only the access token as a string and an error. To additionally obtain other information use GetTokenResponse. On failure an error is returned.
This function requests an access token from oidc-agent according to the passed TokenRequest.
Return Value
The function returns an TokenResponse struct that contains the requested access token, the url of the issuer that issued the token and the time when the token expires.
The following functions can be used to obtain a mytoken from oidc-agent.
Mytoken Request
All functions take a MytokenRequest struct. This struct describes the request:
// MytokenRequest is used to request a mytoken from the agenttypeMytokenRequeststruct {// ShortName that should be used ShortName string// A mytoken profile describing the properties of the requested mytoken// https://mytoken-docs.data.kit.edu/concepts/profiles/ MytokenProfile string// A string describing the requesting application (i.e. its name). It might// be displayed to the user, if the request must be confirmed or an account// configuration loaded. ApplicationHint string}
This function requests a mytoken from oidc-agent according to the passed MytokenRequest.
Return Value
The function returns only the mytoken as a string and an error. To additionally obtain other information use GetMytokenResponse. On failure an error is returned.