-1

Please help. I am trying to search for a specific user in Foursquare but for some reason I got Missing credentials error 401.

user_id = '484542633' # user ID with most agree counts and complete profile

url = 'https://api.foursquare.com/v2/users/{}?client_id={}&client_secret={}&v={}'.format(user_id, CLIENT_ID, CLIENT_SECRET, VERSION) # define URL

# send GET request
results = requests.get(url).json()
user_data = results['response']['user']

# display features associated with user
user_data.keys()

1 Answers1

0

As documentation states, this endpoint is meant to be accessed on behalf of the user:

This endpoint requires user authentication.

User calls require a valid OAuth access token in the query string of each request instead of the Client ID and Secret (&oauth_token=XXXX).

For more information about this authentication method and how to obtain an access token, see the Authentication docs.

This means v2/users can only be accessed by your app, after a user (which can be you, using your own Foursquare account) goes through the OAuth login flow and grants necessary permissions. OAuth doesn't mean your app "logs in" as the user, rather that the user has given you permission to do something on their behalf.

To learn more about OAuth you can watch this talk: https://www.youtube.com/watch?v=996OiexHze0

To read more about Foursquare's API visit their documentation site: https://developer.foursquare.com/docs/api/

Community
  • 1
  • 1
ermik
  • 408
  • 3
  • 17