@@ -55,7 +55,8 @@ const (
5555)
5656
5757type GlobalOptions struct {
58- // AuthenticationMethod is the method we use to authenticate with the jira serivce. Possible values are "api-token" or "session".
58+ // AuthenticationMethod is the method we use to authenticate with the jira serivce.
59+ // Possible values are "api-token", "bearer-token" or "session".
5960 // The default is "api-token" when the service endpoint ends with "atlassian.net", otherwise it "session". Session authentication
6061 // will promt for user password and use the /auth/1/session-login endpoint.
6162 AuthenticationMethod figtree.StringOption `yaml:"authentication-method,omitempty" json:"authentication-method,omitempty"`
@@ -154,6 +155,10 @@ func (o *GlobalOptions) AuthMethod() string {
154155 return o .AuthenticationMethod .Value
155156}
156157
158+ func (o * GlobalOptions ) AuthMethodIsToken () bool {
159+ return o .AuthMethod () == "api-token" || o .AuthMethod () == "bearer-token" ;
160+ }
161+
157162func register (app * kingpin.Application , o * oreo.Client , fig * figtree.FigTree ) {
158163 globals := GlobalOptions {
159164 User : figtree .NewStringOption (os .Getenv ("USER" )),
@@ -177,7 +182,7 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
177182 token := globals .GetPass ()
178183 authHeader := fmt .Sprintf ("Bearer %s" , token )
179184 req .Header .Add ("Authorization" , authHeader )
180- }
185+ }
181186 return req , nil
182187 })
183188
@@ -198,7 +203,7 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
198203 // rerun the original request
199204 return o .Do (req )
200205 }
201- } else if globals .AuthMethod () == "api-token" && resp .StatusCode == 401 {
206+ } else if globals .AuthMethodIsToken () && resp .StatusCode == 401 {
202207 globals .SetPass ("" )
203208 return o .Do (req )
204209 }
@@ -236,7 +241,7 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
236241 } else if globals .SocksProxy .Value != "" {
237242 o = o .WithTransport (socksProxy (globals .SocksProxy .Value ))
238243 }
239- if globals .AuthMethod () == "api-token" {
244+ if globals .AuthMethodIsToken () {
240245 o = o .WithCookieFile ("" )
241246 }
242247 if globals .Login .Value == "" {
0 commit comments