MCPcopy
hub / github.com/ory/hydra / newDeviceClient

Function newDeviceClient

oauth2/oauth2_device_code_test.go:841–875  ·  view source on GitHub ↗
(
	t *testing.T,
	reg interface {
		config.Provider
		client.Registry
	},
	opts ...func(*client.Client),
)

Source from the content-addressed store, hash-verified

839}
840
841func newDeviceClient(
842 t *testing.T,
843 reg interface {
844 config.Provider
845 client.Registry
846 },
847 opts ...func(*client.Client),
848) (*client.Client, *oauth2.Config) {
849 ctx := context.Background()
850 c := &client.Client{
851 GrantTypes: []string{
852 "refresh_token",
853 "urn:ietf:params:oauth:grant-type:device_code",
854 },
855 Scope: "hydra offline openid",
856 Audience: []string{"https://api.ory.sh/"},
857 TokenEndpointAuthMethod: "none",
858 }
859
860 // apply options
861 for _, o := range opts {
862 o(c)
863 }
864
865 require.NoError(t, reg.ClientManager().CreateClient(ctx, c))
866 return c, &oauth2.Config{
867 ClientID: c.GetID(),
868 Endpoint: oauth2.Endpoint{
869 DeviceAuthURL: reg.Config().OAuth2DeviceAuthorisationURL(ctx).String(),
870 TokenURL: reg.Config().OAuth2TokenURL(ctx).String(),
871 AuthStyle: oauth2.AuthStyleInHeader,
872 },
873 Scopes: strings.Split(c.Scope, " "),
874 }
875}

Callers 1

Calls 7

GetIDMethod · 0.95
OAuth2TokenURLMethod · 0.80
CreateClientMethod · 0.65
ClientManagerMethod · 0.65
StringMethod · 0.65
ConfigMethod · 0.65

Tested by

no test coverage detected