@@ -2,7 +2,6 @@ package login
22
33import (
44 "fmt"
5- "os"
65
76 "github.com/AlecAivazis/survey/v2"
87 "github.com/MakeNowJust/heredoc"
@@ -18,23 +17,6 @@ import (
1817 "github.com/algolia/cli/pkg/validators"
1918)
2019
21- // DefaultOAuthClientID is injected at build time via ldflags.
22- // Override with ALGOLIA_OAUTH_CLIENT_ID environment variable for local development.
23- var DefaultOAuthClientID = ""
24-
25- // OAuthClientID returns the OAuth client ID, preferring the ALGOLIA_OAUTH_CLIENT_ID
26- // environment variable over the compiled-in default (set via ldflags).
27- func OAuthClientID () string {
28- if v := os .Getenv ("ALGOLIA_OAUTH_CLIENT_ID" ); v != "" {
29- return v
30- }
31- if DefaultOAuthClientID == "" {
32- fmt .Fprintln (os .Stderr , "fatal: ALGOLIA_OAUTH_CLIENT_ID is not set and no default was compiled in" )
33- os .Exit (1 )
34- }
35- return DefaultOAuthClientID
36- }
37-
3820// LoginOptions holds all options for the login command.
3921type LoginOptions struct {
4022 IO * iostreams.IOStreams
@@ -109,7 +91,7 @@ func runLoginCmd(opts *LoginOptions) error {
10991// If signup is true, the browser opens to the sign-up page instead of sign-in.
11092func RunOAuthFlow (opts * LoginOptions , signup bool ) error {
11193 cs := opts .IO .ColorScheme ()
112- client := opts .NewDashboardClient (OAuthClientID ())
94+ client := opts .NewDashboardClient (auth . OAuthClientID ())
11395
11496 openBrowser := ! opts .NoBrowser
11597 accessToken , err := auth .RunOAuth (opts .IO , client , signup , openBrowser )
0 commit comments