Python - Foursquare API “Missing Auth Credentials'” userless search?












0















I am trying to use the foursquare API for the first time and have not been able to get a 200 status code no matter what I tried. Using directly the code foursquare provides in its docs, I attempt to do a userless request, replacing my client ID and secret where necessary.



def places_search(term,street, zipcode):
params = dict(
client_id='MY_CLIENT_ID',
client_secret='MY_CLIENT_SECRET',
v='20181122',
near=street + 'New York, NY ' + zipcode,
query=term,
limit=1
)
url = "https://api.foursquare.com/v2/venues/explore"
resp = requests.get(url=url, params=params)
#grabbing the JSON result
data = json.loads(resp.text)

return data

print(places_search("starbucks","3rd avenue","10009"))


I get the following error code:



{'meta': {'code': 400, 'errorType': 'invalid_auth', 'errorDetail': 'Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details.', 'requestId': '5bf6cbb26a607137bc33b7f2'}, 'response': {}}


I find it odd given my request is userless and matches exactly the way they outline it in the docs... Would you have an idea what I am doing wrong?



Thanks,










share|improve this question























  • even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

    – user1867507
    Nov 22 '18 at 18:34













  • I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

    – Kosuke Ogawa
    Nov 26 '18 at 1:02
















0















I am trying to use the foursquare API for the first time and have not been able to get a 200 status code no matter what I tried. Using directly the code foursquare provides in its docs, I attempt to do a userless request, replacing my client ID and secret where necessary.



def places_search(term,street, zipcode):
params = dict(
client_id='MY_CLIENT_ID',
client_secret='MY_CLIENT_SECRET',
v='20181122',
near=street + 'New York, NY ' + zipcode,
query=term,
limit=1
)
url = "https://api.foursquare.com/v2/venues/explore"
resp = requests.get(url=url, params=params)
#grabbing the JSON result
data = json.loads(resp.text)

return data

print(places_search("starbucks","3rd avenue","10009"))


I get the following error code:



{'meta': {'code': 400, 'errorType': 'invalid_auth', 'errorDetail': 'Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details.', 'requestId': '5bf6cbb26a607137bc33b7f2'}, 'response': {}}


I find it odd given my request is userless and matches exactly the way they outline it in the docs... Would you have an idea what I am doing wrong?



Thanks,










share|improve this question























  • even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

    – user1867507
    Nov 22 '18 at 18:34













  • I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

    – Kosuke Ogawa
    Nov 26 '18 at 1:02














0












0








0


1






I am trying to use the foursquare API for the first time and have not been able to get a 200 status code no matter what I tried. Using directly the code foursquare provides in its docs, I attempt to do a userless request, replacing my client ID and secret where necessary.



def places_search(term,street, zipcode):
params = dict(
client_id='MY_CLIENT_ID',
client_secret='MY_CLIENT_SECRET',
v='20181122',
near=street + 'New York, NY ' + zipcode,
query=term,
limit=1
)
url = "https://api.foursquare.com/v2/venues/explore"
resp = requests.get(url=url, params=params)
#grabbing the JSON result
data = json.loads(resp.text)

return data

print(places_search("starbucks","3rd avenue","10009"))


I get the following error code:



{'meta': {'code': 400, 'errorType': 'invalid_auth', 'errorDetail': 'Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details.', 'requestId': '5bf6cbb26a607137bc33b7f2'}, 'response': {}}


I find it odd given my request is userless and matches exactly the way they outline it in the docs... Would you have an idea what I am doing wrong?



Thanks,










share|improve this question














I am trying to use the foursquare API for the first time and have not been able to get a 200 status code no matter what I tried. Using directly the code foursquare provides in its docs, I attempt to do a userless request, replacing my client ID and secret where necessary.



def places_search(term,street, zipcode):
params = dict(
client_id='MY_CLIENT_ID',
client_secret='MY_CLIENT_SECRET',
v='20181122',
near=street + 'New York, NY ' + zipcode,
query=term,
limit=1
)
url = "https://api.foursquare.com/v2/venues/explore"
resp = requests.get(url=url, params=params)
#grabbing the JSON result
data = json.loads(resp.text)

return data

print(places_search("starbucks","3rd avenue","10009"))


I get the following error code:



{'meta': {'code': 400, 'errorType': 'invalid_auth', 'errorDetail': 'Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details.', 'requestId': '5bf6cbb26a607137bc33b7f2'}, 'response': {}}


I find it odd given my request is userless and matches exactly the way they outline it in the docs... Would you have an idea what I am doing wrong?



Thanks,







python authentication foursquare






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 15:38









user1867507user1867507

255




255













  • even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

    – user1867507
    Nov 22 '18 at 18:34













  • I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

    – Kosuke Ogawa
    Nov 26 '18 at 1:02



















  • even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

    – user1867507
    Nov 22 '18 at 18:34













  • I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

    – Kosuke Ogawa
    Nov 26 '18 at 1:02

















even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

– user1867507
Nov 22 '18 at 18:34







even using the below that comes right from foursquare and plugging in today's date as well as the client_id and client_secret, i get the same error https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD

– user1867507
Nov 22 '18 at 18:34















I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

– Kosuke Ogawa
Nov 26 '18 at 1:02





I implemented your code and it works fine for me. Maybe your client_id/client_secret is wrong.

– Kosuke Ogawa
Nov 26 '18 at 1:02












1 Answer
1






active

oldest

votes


















0














As per the documentation:




To make a userless request, specify your consumer key’s Client ID and
Secret instead of an auth token in the request URL.




Like this:



https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD


Since you are passing the credentials as the request parameters, the server cannot authenticate you.






share|improve this answer
























  • I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

    – user1867507
    Nov 22 '18 at 16:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434276%2fpython-foursquare-api-missing-auth-credentials-userless-search%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














As per the documentation:




To make a userless request, specify your consumer key’s Client ID and
Secret instead of an auth token in the request URL.




Like this:



https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD


Since you are passing the credentials as the request parameters, the server cannot authenticate you.






share|improve this answer
























  • I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

    – user1867507
    Nov 22 '18 at 16:46
















0














As per the documentation:




To make a userless request, specify your consumer key’s Client ID and
Secret instead of an auth token in the request URL.




Like this:



https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD


Since you are passing the credentials as the request parameters, the server cannot authenticate you.






share|improve this answer
























  • I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

    – user1867507
    Nov 22 '18 at 16:46














0












0








0







As per the documentation:




To make a userless request, specify your consumer key’s Client ID and
Secret instead of an auth token in the request URL.




Like this:



https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD


Since you are passing the credentials as the request parameters, the server cannot authenticate you.






share|improve this answer













As per the documentation:




To make a userless request, specify your consumer key’s Client ID and
Secret instead of an auth token in the request URL.




Like this:



https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=YYYYMMDD


Since you are passing the credentials as the request parameters, the server cannot authenticate you.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 16:12









drec4sdrec4s

1,6122621




1,6122621













  • I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

    – user1867507
    Nov 22 '18 at 16:46



















  • I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

    – user1867507
    Nov 22 '18 at 16:46

















I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

– user1867507
Nov 22 '18 at 16:46





I am still getting the same error with https://api.foursquare.com/v2/venues/search?near=2nd+avenue+12th+streetNew+York%2C+NY+10009&client_id=clientid&client_secret=clientsecret&v=20181122

– user1867507
Nov 22 '18 at 16:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434276%2fpython-foursquare-api-missing-auth-credentials-userless-search%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin