|
|
||
|---|---|---|
| .. | ||
| .openapi-generator | ||
| api | ||
| docs | ||
| .gitignore | ||
| .openapi-generator-ignore | ||
| .travis.yml | ||
| README.md | ||
| api_jwk.go | ||
| api_metadata.go | ||
| api_o_auth2.go | ||
| api_oidc.go | ||
| api_wellknown.go | ||
| client.go | ||
| configuration.go | ||
| git_push.sh | ||
| go.mod | ||
| go.sum | ||
| model_accept_o_auth2_consent_request.go | ||
| model_accept_o_auth2_consent_request_session.go | ||
| model_accept_o_auth2_login_request.go | ||
| model_create_json_web_key_set.go | ||
| model_create_verifiable_credential_request_body.go | ||
| model_credential_supported_draft00.go | ||
| model_error_o_auth2.go | ||
| model_generic_error.go | ||
| model_get_version_200_response.go | ||
| model_health_not_ready_status.go | ||
| model_health_status.go | ||
| model_introspected_o_auth2_token.go | ||
| model_is_ready_200_response.go | ||
| model_is_ready_503_response.go | ||
| model_json_patch.go | ||
| model_json_web_key.go | ||
| model_json_web_key_set.go | ||
| model_o_auth2_client.go | ||
| model_o_auth2_client_token_lifespans.go | ||
| model_o_auth2_consent_request.go | ||
| model_o_auth2_consent_request_open_id_connect_context.go | ||
| model_o_auth2_consent_session.go | ||
| model_o_auth2_consent_session_expires_at.go | ||
| model_o_auth2_login_request.go | ||
| model_o_auth2_logout_request.go | ||
| model_o_auth2_redirect_to.go | ||
| model_o_auth2_token_exchange.go | ||
| model_oidc_configuration.go | ||
| model_oidc_user_info.go | ||
| model_pagination.go | ||
| model_pagination_headers.go | ||
| model_reject_o_auth2_request.go | ||
| model_rfc6749_error_json.go | ||
| model_token_pagination.go | ||
| model_token_pagination_headers.go | ||
| model_token_pagination_request_parameters.go | ||
| model_token_pagination_response_headers.go | ||
| model_trust_o_auth2_jwt_grant_issuer.go | ||
| model_trusted_o_auth2_jwt_grant_issuer.go | ||
| model_trusted_o_auth2_jwt_grant_json_web_key.go | ||
| model_verifiable_credential_priming_response.go | ||
| model_verifiable_credential_proof.go | ||
| model_verifiable_credential_response.go | ||
| model_version.go | ||
| response.go | ||
| utils.go | ||
README.md
Go API client for openapi
Documentation for all of Ory Hydra's APIs.
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version:
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import openapi "github.com/ory/hydra-client-go/v2"
To use a proxy, set the environment variable HTTP_PROXY:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers map in the Configuration.
An operation is uniquely identified by "{classname}Service.{nickname}" string.
Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to http://localhost
| Class | Method | HTTP request | Description |
|---|---|---|---|
| JwkApi | CreateJsonWebKeySet | Post /admin/keys/{set} | Create JSON Web Key |
| JwkApi | DeleteJsonWebKey | Delete /admin/keys/{set}/{kid} | Delete JSON Web Key |
| JwkApi | DeleteJsonWebKeySet | Delete /admin/keys/{set} | Delete JSON Web Key Set |
| JwkApi | GetJsonWebKey | Get /admin/keys/{set}/{kid} | Get JSON Web Key |
| JwkApi | GetJsonWebKeySet | Get /admin/keys/{set} | Retrieve a JSON Web Key Set |
| JwkApi | SetJsonWebKey | Put /admin/keys/{set}/{kid} | Set JSON Web Key |
| JwkApi | SetJsonWebKeySet | Put /admin/keys/{set} | Update a JSON Web Key Set |
| MetadataApi | GetVersion | Get /version | Return Running Software Version. |
| MetadataApi | IsAlive | Get /health/alive | Check HTTP Server Status |
| MetadataApi | IsReady | Get /health/ready | Check HTTP Server and Database Status |
| OAuth2Api | AcceptOAuth2ConsentRequest | Put /admin/oauth2/auth/requests/consent/accept | Accept OAuth 2.0 Consent Request |
| OAuth2Api | AcceptOAuth2LoginRequest | Put /admin/oauth2/auth/requests/login/accept | Accept OAuth 2.0 Login Request |
| OAuth2Api | AcceptOAuth2LogoutRequest | Put /admin/oauth2/auth/requests/logout/accept | Accept OAuth 2.0 Session Logout Request |
| OAuth2Api | CreateOAuth2Client | Post /admin/clients | Create OAuth 2.0 Client |
| OAuth2Api | DeleteOAuth2Client | Delete /admin/clients/{id} | Delete OAuth 2.0 Client |
| OAuth2Api | DeleteOAuth2Token | Delete /admin/oauth2/tokens | Delete OAuth 2.0 Access Tokens from specific OAuth 2.0 Client |
| OAuth2Api | DeleteTrustedOAuth2JwtGrantIssuer | Delete /admin/trust/grants/jwt-bearer/issuers/{id} | Delete Trusted OAuth2 JWT Bearer Grant Type Issuer |
| OAuth2Api | GetOAuth2Client | Get /admin/clients/{id} | Get an OAuth 2.0 Client |
| OAuth2Api | GetOAuth2ConsentRequest | Get /admin/oauth2/auth/requests/consent | Get OAuth 2.0 Consent Request |
| OAuth2Api | GetOAuth2LoginRequest | Get /admin/oauth2/auth/requests/login | Get OAuth 2.0 Login Request |
| OAuth2Api | GetOAuth2LogoutRequest | Get /admin/oauth2/auth/requests/logout | Get OAuth 2.0 Session Logout Request |
| OAuth2Api | GetTrustedOAuth2JwtGrantIssuer | Get /admin/trust/grants/jwt-bearer/issuers/{id} | Get Trusted OAuth2 JWT Bearer Grant Type Issuer |
| OAuth2Api | IntrospectOAuth2Token | Post /admin/oauth2/introspect | Introspect OAuth2 Access and Refresh Tokens |
| OAuth2Api | ListOAuth2Clients | Get /admin/clients | List OAuth 2.0 Clients |
| OAuth2Api | ListOAuth2ConsentSessions | Get /admin/oauth2/auth/sessions/consent | List OAuth 2.0 Consent Sessions of a Subject |
| OAuth2Api | ListTrustedOAuth2JwtGrantIssuers | Get /admin/trust/grants/jwt-bearer/issuers | List Trusted OAuth2 JWT Bearer Grant Type Issuers |
| OAuth2Api | OAuth2Authorize | Get /oauth2/auth | OAuth 2.0 Authorize Endpoint |
| OAuth2Api | Oauth2TokenExchange | Post /oauth2/token | The OAuth 2.0 Token Endpoint |
| OAuth2Api | PatchOAuth2Client | Patch /admin/clients/{id} | Patch OAuth 2.0 Client |
| OAuth2Api | RejectOAuth2ConsentRequest | Put /admin/oauth2/auth/requests/consent/reject | Reject OAuth 2.0 Consent Request |
| OAuth2Api | RejectOAuth2LoginRequest | Put /admin/oauth2/auth/requests/login/reject | Reject OAuth 2.0 Login Request |
| OAuth2Api | RejectOAuth2LogoutRequest | Put /admin/oauth2/auth/requests/logout/reject | Reject OAuth 2.0 Session Logout Request |
| OAuth2Api | RevokeOAuth2ConsentSessions | Delete /admin/oauth2/auth/sessions/consent | Revoke OAuth 2.0 Consent Sessions of a Subject |
| OAuth2Api | RevokeOAuth2LoginSessions | Delete /admin/oauth2/auth/sessions/login | Revokes OAuth 2.0 Login Sessions by either a Subject or a SessionID |
| OAuth2Api | RevokeOAuth2Token | Post /oauth2/revoke | Revoke OAuth 2.0 Access or Refresh Token |
| OAuth2Api | SetOAuth2Client | Put /admin/clients/{id} | Set OAuth 2.0 Client |
| OAuth2Api | SetOAuth2ClientLifespans | Put /admin/clients/{id}/lifespans | Set OAuth2 Client Token Lifespans |
| OAuth2Api | TrustOAuth2JwtGrantIssuer | Post /admin/trust/grants/jwt-bearer/issuers | Trust OAuth2 JWT Bearer Grant Type Issuer |
| OidcApi | CreateOidcDynamicClient | Post /oauth2/register | Register OAuth2 Client using OpenID Dynamic Client Registration |
| OidcApi | CreateVerifiableCredential | Post /credentials | Issues a Verifiable Credential |
| OidcApi | DeleteOidcDynamicClient | Delete /oauth2/register/{id} | Delete OAuth 2.0 Client using the OpenID Dynamic Client Registration Management Protocol |
| OidcApi | DiscoverOidcConfiguration | Get /.well-known/openid-configuration | OpenID Connect Discovery |
| OidcApi | GetOidcDynamicClient | Get /oauth2/register/{id} | Get OAuth2 Client using OpenID Dynamic Client Registration |
| OidcApi | GetOidcUserInfo | Get /userinfo | OpenID Connect Userinfo |
| OidcApi | RevokeOidcSession | Get /oauth2/sessions/logout | OpenID Connect Front- and Back-channel Enabled Logout |
| OidcApi | SetOidcDynamicClient | Put /oauth2/register/{id} | Set OAuth2 Client using OpenID Dynamic Client Registration |
| WellknownApi | DiscoverJsonWebKeys | Get /.well-known/jwks.json | Discover Well-Known JSON Web Keys |
Documentation For Models
- AcceptOAuth2ConsentRequest
- AcceptOAuth2ConsentRequestSession
- AcceptOAuth2LoginRequest
- CreateJsonWebKeySet
- CreateVerifiableCredentialRequestBody
- CredentialSupportedDraft00
- ErrorOAuth2
- GenericError
- GetVersion200Response
- HealthNotReadyStatus
- HealthStatus
- IntrospectedOAuth2Token
- IsReady200Response
- IsReady503Response
- JsonPatch
- JsonWebKey
- JsonWebKeySet
- OAuth2Client
- OAuth2ClientTokenLifespans
- OAuth2ConsentRequest
- OAuth2ConsentRequestOpenIDConnectContext
- OAuth2ConsentSession
- OAuth2ConsentSessionExpiresAt
- OAuth2LoginRequest
- OAuth2LogoutRequest
- OAuth2RedirectTo
- OAuth2TokenExchange
- OidcConfiguration
- OidcUserInfo
- Pagination
- PaginationHeaders
- RFC6749ErrorJson
- RejectOAuth2Request
- TokenPagination
- TokenPaginationHeaders
- TokenPaginationRequestParameters
- TokenPaginationResponseHeaders
- TrustOAuth2JwtGrantIssuer
- TrustedOAuth2JwtGrantIssuer
- TrustedOAuth2JwtGrantJsonWebKey
- VerifiableCredentialPrimingResponse
- VerifiableCredentialProof
- VerifiableCredentialResponse
- Version
Documentation For Authorization
Authentication schemes defined for the API:
basic
- Type: HTTP basic authentication
Example
auth := context.WithValue(context.Background(), openapi.ContextBasicAuth, openapi.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
bearer
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
oauth2
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://hydra.demo.ory.sh/oauth2/auth
- Scopes:
- offline: A scope required when requesting refresh tokens (alias for
offline_access) - offline_access: A scope required when requesting refresh tokens
- openid: Request an OpenID Connect ID Token
Example
auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
import "golang.org/x/oauth2"
/* Perform OAuth2 round trip request and obtain a token */
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBoolPtrIntPtrInt32PtrInt64PtrFloatPtrFloat32PtrFloat64PtrStringPtrTime