DoManualAuthorization performs the log in into the identity provider allowing the user to open a browser on a different system and then entering the authorization code on the Step CLI.
()
| 817 | // allowing the user to open a browser on a different system and then entering |
| 818 | // the authorization code on the Step CLI. |
| 819 | func (o *oauth) DoManualAuthorization() (*token, error) { |
| 820 | o.redirectURI = oobCallbackUrn |
| 821 | authURL, err := o.Auth() |
| 822 | if err != nil { |
| 823 | return nil, err |
| 824 | } |
| 825 | |
| 826 | fmt.Fprintln(os.Stderr, "Open a local web browser and visit:") |
| 827 | fmt.Fprintln(os.Stderr) |
| 828 | fmt.Fprintln(os.Stderr, authURL) |
| 829 | fmt.Fprintln(os.Stderr) |
| 830 | |
| 831 | // Read from the command line |
| 832 | fmt.Fprint(os.Stderr, "Enter verification code: ") |
| 833 | code, err := utils.ReadString(os.Stdin) |
| 834 | if err != nil { |
| 835 | return nil, errors.WithStack(err) |
| 836 | } |
| 837 | |
| 838 | tok, err := o.Exchange(o.tokenEndpoint, code) |
| 839 | if err != nil { |
| 840 | return nil, err |
| 841 | } |
| 842 | if tok.Err != "" || tok.ErrDesc != "" { |
| 843 | return nil, errors.Errorf("Error exchanging authorization code: %s. %s", tok.Err, tok.ErrDesc) |
| 844 | } |
| 845 | return tok, nil |
| 846 | } |
| 847 | |
| 848 | type identifyDeviceResponse struct { |
| 849 | DeviceCode string `json:"device_code"` |
no test coverage detected