Skip to content

Commit

Permalink
Merge pull request #196 from manifoldco/improvements/get-oauth-poll
Browse files Browse the repository at this point in the history
Use GET request for OAuth polling
  • Loading branch information
enmand authored Dec 13, 2017
2 parents 547a6ce + 297ce97 commit 176c9e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- GitHub identity -- register a new account, login to or link an existing account to GitHub
- GitHub identity -- update GitHub app ClientID
- GitHub identity -- Use GET for state polling
- Reference to go-manifold updated to 0.9.1 release for verification code change

## [0.12.0] - 2017-11-30
Expand Down
11 changes: 4 additions & 7 deletions cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/manifoldco/manifold-cli/config"
"github.com/manifoldco/manifold-cli/api"
"github.com/manifoldco/manifold-cli/generated/identity/client/authentication"
"github.com/manifoldco/manifold-cli/generated/identity/models"
)

var (
Expand Down Expand Up @@ -78,19 +77,17 @@ func githubWithCallback(ctx context.Context, cfg *config.Config, a *analytics.An
timeout := time.After(pollingTimeout)
tick := time.Tick(pollingTick)

op := authentication.NewPostTokensOauthPollParamsWithContext(ctx)
op.SetBody(&models.OAuthAuthenticationPoll{
Secret: &state,
})
op := authentication.NewGetTokensOauthPollParamsWithContext(ctx)
op.Secret = state
for {
select {
case <-timeout:
return cli.NewExitError("Unable to fetch authentication", -1)
case <-tick:
loginResp, linkResp, err := identityClient.Identity.Authentication.PostTokensOauthPoll(op)
loginResp, linkResp, err := identityClient.Identity.Authentication.GetTokensOauthPoll(op)
if err != nil {
switch err.(type) {
case *authentication.PostTokensOauthPollNotFound:
case *authentication.GetTokensOauthPollNotFound:
continue
default:
return err
Expand Down
11 changes: 5 additions & 6 deletions specs/identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@ paths:
schema:
$ref: '#/definitions/Error'
/tokens/oauth/poll:
post:
get:
security: []
summary: Poll the exchange of a third-party OAuth 2 token for valid authentication
parameters:
- name: body
in: body
- name: secret
in: query
description: |
OAuth state information
The state secret to poll for authorization
type: string
required: true
schema:
$ref: '#/definitions/OAuthAuthenticationPoll'
tags:
- Authentication
responses:
Expand Down

0 comments on commit 176c9e7

Please sign in to comment.