diff --git a/pkg/client/client.go b/pkg/client/client.go index e5e8e3b..9b73fa0 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/nspcc-dev/neofs-api-go/pkg" + "github.com/nspcc-dev/neofs-api-go/pkg/token" ) type ( @@ -13,6 +14,10 @@ type ( remoteNode TransportInfo opts *clientOptions + + sessionToken *token.SessionToken + + bearerToken *token.BearerToken } TransportProtocol uint32 diff --git a/pkg/client/opts.go b/pkg/client/opts.go index f8d2528..6c204e7 100644 --- a/pkg/client/opts.go +++ b/pkg/client/opts.go @@ -62,6 +62,8 @@ func (c Client) defaultCallOptions() callOptions { return callOptions{ ttl: 2, version: pkg.SDKVersion(), + session: c.sessionToken, + bearer: c.bearerToken, } } diff --git a/pkg/client/session.go b/pkg/client/session.go index 48d0806..7f9d6a0 100644 --- a/pkg/client/session.go +++ b/pkg/client/session.go @@ -110,3 +110,19 @@ func v2SessionClientFromOptions(opts *clientOptions) (cli *v2session.Client, err return cli, nil } + +// AttachSessionToken attaches session token to client. +// +// Provided token is attached to all requests without WithSession option. +// Use WithSession(nil) option in order to send request without session token. +func (c *Client) AttachSessionToken(token *token.SessionToken) { + c.sessionToken = token +} + +// AttachBearerToken attaches bearer token to client. +// +// Provided bearer is attached to all requests without WithBearer option. +// Use WithBearer(nil) option in order to send request without bearer token. +func (c *Client) AttachBearerToken(token *token.BearerToken) { + c.bearerToken = token +}