Skip to content

Commit

Permalink
Merge pull request #205 from adamo57/adamo57-migrate-dropbox-endpoint
Browse files Browse the repository at this point in the history
Migrated Dropbox endpoints to use v2
  • Loading branch information
bentranter committed Feb 15, 2018
2 parents 6460443 + b5d90c5 commit bc7deaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions providers/dropbox/dropbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import (
"strings"

"fmt"

"github.com/markbates/goth"
"golang.org/x/oauth2"
)

const (
authURL = "https://www.dropbox.com/1/oauth2/authorize"
tokenURL = "https://api.dropbox.com/1/oauth2/token"
accountURL = "https://api.dropbox.com/1/account/info"
authURL = "https://www.dropbox.com/oauth2/authorize"
tokenURL = "https://api.dropbox.com/oauth2/token"
accountURL = "https://api.dropbox.com/2/users/get_current_account"
)

// Provider is the implementation of `goth.Provider` for accessing Dropbox.
Expand Down Expand Up @@ -86,7 +87,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
return user, fmt.Errorf("%s cannot get user information without accessToken", p.providerName)
}

req, err := http.NewRequest("GET", accountURL, nil)
req, err := http.NewRequest("POST", accountURL, nil)
if err != nil {
return user, err
}
Expand Down
6 changes: 3 additions & 3 deletions providers/dropbox/dropbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ func Test_BeginAuth(t *testing.T) {
session, err := p.BeginAuth("test_state")
s := session.(*Session)
a.NoError(err)
a.Contains(s.AuthURL, "www.dropbox.com/1/oauth2/authorize")
a.Contains(s.AuthURL, "www.dropbox.com/oauth2/authorize")
}

func Test_SessionFromJSON(t *testing.T) {
t.Parallel()
a := assert.New(t)

p := provider()
session, err := p.UnmarshalSession(`{"AuthURL":"https://www.dropbox.com/1/oauth2/authorize","Token":"1234567890"}`)
session, err := p.UnmarshalSession(`{"AuthURL":"https://www.dropbox.com/oauth2/authorize","Token":"1234567890"}`)
a.NoError(err)

s := session.(*Session)
a.Equal(s.AuthURL, "https://www.dropbox.com/1/oauth2/authorize")
a.Equal(s.AuthURL, "https://www.dropbox.com/oauth2/authorize")
a.Equal(s.Token, "1234567890")
}

Expand Down

0 comments on commit bc7deaf

Please sign in to comment.