Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit 9830c60

Browse files
committed
fix new app creation flow with account keys
* new app creation was not functional with account keys * print better error messages if account keys are not configured
1 parent 194eb8e commit 9830c60

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

apps.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,10 @@ func (a *apps) restCreateApp(e *env, appName string) (*app, error) {
207207
req := &http.Request{
208208
Method: "POST",
209209
URL: &url.URL{Path: "apps"},
210-
Header: make(http.Header),
210+
Header: getAuthHeaders(&a.login.credentials, nil),
211211
Body: ioutil.NopCloser(jsonpipe.Encode(map[string]string{"appName": appName})),
212212
}
213213

214-
req.Header.Add("X-Parse-Email", a.login.credentials.email)
215-
req.Header.Add("X-Parse-Password", a.login.credentials.password)
216-
217214
var res app
218215
if response, err := e.Client.Do(req, nil, &res); err != nil {
219216
if response != nil && response.StatusCode == http.StatusUnauthorized {

configure_cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type configureCmd struct {
1414
func (c *configureCmd) accessToken(e *env) error {
1515
fmt.Fprintf(e.Out,
1616
`Please enter an access token if you already generated it.
17+
1718
If you do not have an access token or would like to generate a new one,
1819
please type: "y" to open the browser or "n" to continue: `,
1920
)

configure_cmd_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ func TestConfigureAcessToken(t *testing.T) {
2121
ensure.DeepEqual(t,
2222
h.Out.String(),
2323
`Please enter an access token if you already generated it.
24+
2425
If you do not have an access token or would like to generate a new one,
25-
please type: "y" to open the browser or "n" to continue: Access Token: Successfully stored credentials.
26-
`,
27-
)
26+
please type: "y" to open the browser or "n" to continue: Please open "https://www.parse.com/account_keys" in the browser
27+
and follow instructions to create an access token.
28+
Access Token: Successfully stored credentials.
29+
`)
2830
h.env.In = ioutil.NopCloser(strings.NewReader("n\nemail\ninvalid\n"))
2931
ensure.Err(t, c.accessToken(h.env), regexp.MustCompile("Please try again"))
3032
ensure.DeepEqual(t,

login.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ func (l *login) authUserWithToken(e *env) error {
168168
_, err = apps.restFetchApps(e)
169169
if err == errAuth {
170170
fmt.Fprintln(e.Err,
171-
`Sorry, you have an invalid token associated with the email: %q.
171+
`Sorry, the token you configured is not valid.
172172
To avoid typing the email and password everytime,
173-
please type "parse configure token" and provide a valid access token.`,
174-
)
173+
please type "parse configure token" and provide a valid access token.
174+
`)
175175
}
176176
if err != nil {
177177
return stackerr.Wrap(err)
@@ -216,6 +216,12 @@ func (l *login) helpCreateToken(e *env) {
216216
var shouldOpen string
217217
fmt.Fscanf(e.In, "%s\n", &shouldOpen)
218218
if shouldOpen == "n" {
219+
fmt.Fprintf(e.Out,
220+
`Please open %q in the browser
221+
and follow instructions to create an access token.
222+
`,
223+
keysURL,
224+
)
219225
return
220226
}
221227
err := open.Run(keysURL)

0 commit comments

Comments
 (0)