You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(oauth): use oauth flow to authenticate with predefined src-cli OAuth client (#1223)
* removed unused func
* add refresh token to device response unmarshall
* make NewClient take ClientID as param
* add oauth flow and use oauth token when SRC_ACCESS_TOKEN is empty
* feat(oauth): Add refresh to oauthdevice.Client (#1227)
* add refresh to oauthdevice.Client
* oauthdevice: add RefreshToken field and Refresh method
* feat(oauth): Use keyring to store oauth token (#1228)
* add refresh to oauthdevice.Client
* add OAuth Transport and use it if no access token
* secrets: switch to zalando/go-keyring and add context support
* secrets: scope keyring by endpoint
(cherry picked from commit 0bc535e)
wantOut:="❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://sourcegraph.example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://sourcegraph.example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again."
37
+
wantOut:="❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://sourcegraph.example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://sourcegraph.example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again.\n\n Alternatively, you can try logging in using OAuth by running: src login --oauth https://sourcegraph.example.com"
31
38
ifout!=wantOut {
32
39
t.Errorf("got output %q, want %q", out, wantOut)
33
40
}
@@ -38,7 +45,7 @@ func TestLogin(t *testing.T) {
38
45
iferr!=cmderrors.ExitCode1 {
39
46
t.Fatal(err)
40
47
}
41
-
wantOut:="❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://sourcegraph.example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://sourcegraph.example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again."
48
+
wantOut:="❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://sourcegraph.example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://sourcegraph.example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again.\n\n Alternatively, you can try logging in using OAuth by running: src login --oauth https://sourcegraph.example.com"
42
49
ifout!=wantOut {
43
50
t.Errorf("got output %q, want %q", out, wantOut)
44
51
}
@@ -49,7 +56,7 @@ func TestLogin(t *testing.T) {
49
56
iferr!=cmderrors.ExitCode1 {
50
57
t.Fatal(err)
51
58
}
52
-
wantOut:="⚠️ Warning: Configuring src with a JSON file is deprecated. Please migrate to using the env vars SRC_ENDPOINT, SRC_ACCESS_TOKEN, and SRC_PROXY instead, and then remove f. See https://github.com/sourcegraph/src-cli#readme for more information.\n\n❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again."
59
+
wantOut:="⚠️ Warning: Configuring src with a JSON file is deprecated. Please migrate to using the env vars SRC_ENDPOINT, SRC_ACCESS_TOKEN, and SRC_PROXY instead, and then remove f. See https://github.com/sourcegraph/src-cli#readme for more information.\n\n❌ Problem: No access token is configured.\n\n🛠 To fix: Create an access token by going to https://example.com/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=https://example.com\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again.\n\n Alternatively, you can try logging in using OAuth by running: src login --oauth https://example.com"
53
60
ifout!=wantOut {
54
61
t.Errorf("got output %q, want %q", out, wantOut)
55
62
}
@@ -67,7 +74,7 @@ func TestLogin(t *testing.T) {
67
74
iferr!=cmderrors.ExitCode1 {
68
75
t.Fatal(err)
69
76
}
70
-
wantOut:="❌ Problem: Invalid access token.\n\n🛠 To fix: Create an access token by going to $ENDPOINT/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=$ENDPOINT\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again.\n\n (If you need to supply custom HTTP request headers, see information about SRC_HEADER_* and SRC_HEADERS env vars at https://github.com/sourcegraph/src-cli/blob/main/AUTH_PROXY.md)"
77
+
wantOut:="❌ Problem: Invalid access token.\n\n🛠 To fix: Create an access token by going to $ENDPOINT/user/settings/tokens, then set the following environment variables in your terminal:\n\n export SRC_ENDPOINT=$ENDPOINT\n export SRC_ACCESS_TOKEN=(your access token)\n\n To verify that it's working, run the login command again.\n\nAlternatively, you can try logging in using OAuth by running: src login --oauth $ENDPOINT\n\n(If you need to supply custom HTTP request headers, see information about SRC_HEADER_* and SRC_HEADERS env vars at https://github.com/sourcegraph/src-cli/blob/main/AUTH_PROXY.md)"
0 commit comments