Documentation
¶
Overview ¶
Package SDK offers convenience functions for Go code around Hydra's HTTP APIs.
import "github.com/ory-am/hydra/sdk"
import "github.com/ory-am/hydra/client"
var hydra, err = sdk.Connect(
sdk.ClientID("client-id"),
sdk.ClientSecret("client-secret"),
sdk.ClusterURL("https://localhost:4444"),
)
// You now have access to the various API endpoints of hydra, for example the oauth2 client endpoint:
var newClient, err = hydra.Client.CreateClient(&client.Client{
ID: "deadbeef",
Secret: "sup3rs3cret",
RedirectURIs: []string{"http://yourapp/callback"},
// ...
})
// Retrieve newly created client
var gotClient, err = hydra.Client.GetClient(newClient.ID)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientID ¶
func ClientID(id string) option
ClientID sets the OAuth2 Client ID.
var hydra, err = sdk.Connect(
sdk.ClientID("client-id"),
)
func ClientSecret ¶
func ClientSecret(secret string) option
ClientSecret sets OAuth2 Client secret.
var hydra, err = sdk.Connect(
sdk.ClientSecret("client-secret"),
)
func ClusterURL ¶
func ClusterURL(urlStr string) option
ClusterURL sets Hydra service URL
var hydra, err = sdk.Connect(
sdk.ClientID("https://localhost:1234/"),
)
func Scopes ¶
func Scopes(scopes ...string) option
Scopes is a list of scopes that are requested in the client credentials grant.
var hydra, err = sdk.Connect(
sdk.Scopes("foo", "bar"),
)
func SkipTLSVerify ¶
func SkipTLSVerify() option
SkipTLSVerify skips TLS verification for HTTPS connections.
var hydra, err = sdk.Connect( sdk.SkipTLSVerify(), )
Types ¶
type Client ¶
type Client struct {
// Clients offers OAuth2 Client management capabilities.
Clients *client.HTTPManager
// JSONWebKeys offers JSON Web Key management capabilities.
JSONWebKeys *jwk.HTTPManager
// Policies offers Access Policy management capabilities.
Policies *policy.HTTPManager
// Warden offers Access Token and Access Request validation strategies (for first-party resource servers).
Warden *warden.HTTPWarden
// Introspection offers Access Token and Access Request introspection strategies (according to RFC 7662).
Introspection *hoauth2.HTTPIntrospector
// Revocation offers OAuth2 Token Revocation.
Revocator *hoauth2.HTTPRecovator
// contains filtered or unexported fields
}
Client offers easy use of all HTTP clients.
func Connect ¶
Connect instantiates a new client to communicate with Hydra.
import "github.com/ory-am/hydra/sdk"
var hydra, err = sdk.Connect(
sdk.ClientID("client-id"),
sdk.ClientSecret("client-secret"),
sdk.ClusterURL("https://localhost:4444"),
)
func (*Client) OAuth2Config ¶ added in v0.4.0
OAuth2Config returns an oauth2 config instance which you can use to initiate various oauth2 flows.
config := client.OAuth2Config("https://mydomain.com/oauth2_callback", "photos", "contacts.read")
redirectRequestTo := oauth2.AuthCodeURL()
// in callback handler...
token, err := config.Exchange(oauth2.NoContext, authorizeCode)
Click to show internal directories.
Click to hide internal directories.