@@ -13,6 +13,7 @@ import (
13
13
"github.com/oidc-mytoken/client/internal/config"
14
14
cutils "github.com/oidc-mytoken/client/internal/utils"
15
15
"github.com/oidc-mytoken/client/internal/utils/profile"
16
+ "github.com/oidc-mytoken/client/internal/utils/qr"
16
17
)
17
18
18
19
type restrictionOpts struct {
@@ -474,9 +475,9 @@ func obtainMT(context *cli.Context) (string, error) {
474
475
if req .Name != "" && prefix != "" {
475
476
req .Name = fmt .Sprintf ("%s:%s" , prefix , req .Name )
476
477
}
478
+ req .ApplicationName = fmt .Sprintf ("mytoken client on %s" , config .Get ().Hostname )
477
479
if ssh := mtCommand .SSH (); ssh != "" {
478
480
req .GrantType = api .GrantTypeSSH
479
- req .ApplicationName = "mytoken client"
480
481
mt , err := doSSHReturnOutput (ssh , api .SSHRequestMytoken , req )
481
482
if mt != "" && mt [len (mt )- 1 ] == '\n' {
482
483
mt = mt [:len (mt )- 1 ]
@@ -506,10 +507,15 @@ func obtainMT(context *cli.Context) (string, error) {
506
507
}
507
508
callbacks := mytokenlib.PollingCallbacks {
508
509
Init : func (authorizationURL string ) error {
509
- _ , _ = fmt .Fprintln (os .Stderr , "Using any device please visit the following url to continue:" )
510
+ _ , _ = fmt .Fprintln (
511
+ os .Stderr ,
512
+ "Using any device please visit the following url to continue or use the qr code:" ,
513
+ )
510
514
_ , _ = fmt .Fprintln (os .Stderr )
511
515
_ , _ = fmt .Fprintln (os .Stderr , authorizationURL )
512
516
_ , _ = fmt .Fprintln (os .Stderr )
517
+ qr .FPrintQR (os .Stderr , authorizationURL )
518
+ _ , _ = fmt .Fprintln (os .Stderr )
513
519
return nil
514
520
},
515
521
Callback : func (interval int64 , iteration int ) {
@@ -526,7 +532,6 @@ func obtainMT(context *cli.Context) (string, error) {
526
532
_ , _ = fmt .Fprintln (os .Stderr , "success" )
527
533
},
528
534
}
529
- return mytoken .Mytoken .FromAuthorizationFlow (
530
- req .Issuer , req .Restrictions , req .Capabilities , req .Rotation , req .ResponseType , req .Name , callbacks ,
531
- )
535
+ resp , err := mytoken .Mytoken .APIFromAuthorizationFlowReq (* req , callbacks )
536
+ return resp .Mytoken , err
532
537
}
0 commit comments