forked from TrueCloudLab/frostfs-api-go
[#143] sdk/client: Add call option to set bearer token
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
96de0bd25a
commit
59033d330d
1 changed files with 11 additions and 1 deletions
|
@ -30,7 +30,7 @@ type (
|
||||||
ttl uint32
|
ttl uint32
|
||||||
epoch uint64
|
epoch uint64
|
||||||
session *token.SessionToken
|
session *token.SessionToken
|
||||||
// add bearer token
|
bearer *token.BearerToken
|
||||||
}
|
}
|
||||||
|
|
||||||
clientOptions struct {
|
clientOptions struct {
|
||||||
|
@ -107,6 +107,12 @@ func WithSession(token *token.SessionToken) CallOption {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithBearer(token *token.BearerToken) CallOption {
|
||||||
|
return newFuncCallOption(func(option *callOptions) {
|
||||||
|
option.bearer = token
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func v2MetaHeaderFromOpts(options callOptions) *v2session.RequestMetaHeader {
|
func v2MetaHeaderFromOpts(options callOptions) *v2session.RequestMetaHeader {
|
||||||
meta := new(v2session.RequestMetaHeader)
|
meta := new(v2session.RequestMetaHeader)
|
||||||
meta.SetVersion(options.version.ToV2())
|
meta.SetVersion(options.version.ToV2())
|
||||||
|
@ -120,6 +126,10 @@ func v2MetaHeaderFromOpts(options callOptions) *v2session.RequestMetaHeader {
|
||||||
|
|
||||||
meta.SetXHeaders(xhdrs)
|
meta.SetXHeaders(xhdrs)
|
||||||
|
|
||||||
|
if options.bearer != nil {
|
||||||
|
meta.SetBearerToken(options.bearer.ToV2())
|
||||||
|
}
|
||||||
|
|
||||||
return meta
|
return meta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue