3
Yelp docsによると:「アクセストークンでAPI呼び出しを認証するには、認証HTTPヘッダー値をBearer access_tokenとして設定してください。 https://www.yelp.com/developers/documentation/v3/get_startedPythonリクエストによるYelp Fusion APIの認証
私はrequests
を使用してYelpのAPIアクセストークンを得ているが、認証することができません。
>>> data = {"grant_type": "client_credentials", "client_id": "foo", "client_secret": "bar"}
>>> r = requests.post("https://api.yelp.com/oauth2/token", data=data)
>>> r
<Response [200]>
>>> r.text
'{"expires_in": 15550795, "token_type": "Bearer", "access_token": "foobar"}'
>>> params = json.loads(r.text)
>>> url = "https://api.yelp.com/v3/autocomplete?text=del&latitude=37.786882&longitude=-122.399972&"
>>> test = requests.get(url, params=params)
>>> test.text
'{"error": {"description": "An access token must be supplied in order to use this endpoint.", "code": "TOKEN_MISSING"}}'