Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth example doesn't work as expected #4

Open
B-Stefan opened this issue Jan 7, 2019 · 2 comments
Open

OAuth example doesn't work as expected #4

B-Stefan opened this issue Jan 7, 2019 · 2 comments

Comments

@B-Stefan
Copy link
Owner

B-Stefan commented Jan 7, 2019

The example is not working because the accessToken is invalid for the /profiles request.
This causes the 401 response from the Buffer API.

A possible explanation is that https://api.bufferapp.com/1/oauth2/token.json returns an API token with inadequate scopes. Or the OAuth lib has been configured incorrectly.

Steps to reproduce

  1. Create a new Buffer app with the redirect url: http://127.0.0.1:9999/oauth/callback
  2. Download go-buffer v0.0.1
  3. ./go-buffer -clientId <YourClientId> -clientSecret <YourClientSecret>
  4. Follow the OAuth process
  5. See error message inside console

Used tools

  • go version go1.11.1 darwin/amd64
  • golang.org/x/oauth2

Output

2019/01/08 00:21:50 You will now be taken to your browser for authentication
2019/01/08 00:21:52 Authentication URL: https://bufferapp.com/oauth2/authorize?access_type=online&client_id=5c32a3174b1be71532161683&redirect_uri=http%3A%2F%2F127.0.0.1%3A9999%2Foauth%2Fcallback&response_type=code&state=state
2019/01/08 00:21:54 code: 1/758a743876aed......
2019/01/08 00:21:55 Token: &{1/3ddd71......   0001-01-01 00:00:00 +0000 UTC map[access_token:1/3ddd7.......scope:<nil>]}
2019/01/08 00:21:55 Authentication successful
2019/01/08 00:21:55 Invalid request. Status code was 401

Performed request

Here is the curl representation of the request that the go-buffer lib has executed

curl -X GET \
  https://api.bufferapp.com/1/profiles.json \
  -H 'authorization: Bearer 1/3ddd71......' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' 

Response: 
{
    "error": "The provided access token is invalid",
    "code": 401
}

Expected behavior

  • /profiles should return 200 as status code
  • /profiles should return the profiles for the user
@B-Stefan
Copy link
Owner Author

B-Stefan commented Jan 8, 2019

Reported to buffer support team for further investigation.

@B-Stefan B-Stefan pinned this issue Jan 8, 2019
@B-Stefan
Copy link
Owner Author

B-Stefan commented Feb 4, 2019

Got response from Buffer Team.
There is a need to reproduce this problem without any library. For example, create a more general approach to reproduce this issue. E.g. a bash script with curl commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant