[英]Unsplash API OAuth error: The access token is invalid
I am using the /search/photos
endpoint of Unsplash's API to retrieve pictures given a specific query.我正在使用Unsplash 的 API的/search/photos
端点来检索给定特定查询的图片。
Here is the get request:这是获取请求:
unsplash_request_url = "https://api.unsplash.com/search/photos?query=#{query}&content_filter=high&client_id=#{ENV['UNSPLASH_ACCESS_KEY']}"
html = URI.open(unsplash_request_url)
return JSON.parse(Nokogiri::HTML(html.read))
As stated in the documentation, I pass the Access token I got with the client_id
parameter.如文档中所述,我传递了使用client_id
参数获得的访问令牌。
However, I get the following error:但是,我收到以下错误:
OAuth error: The access token is invalid OAuth 错误:访问令牌无效
I tried to remove the client_id
parameter and add the access token in the Authorization header, but I get the same error.我试图删除client_id
参数并在授权 header 中添加访问令牌,但我得到了同样的错误。
Any idea how to solve this issue?知道如何解决这个问题吗? Thanks.谢谢。
Make sure you are providing the access key and not the secret key to the endpoint.确保您提供的是访问密钥而不是端点的秘密密钥。
I tested your code with an access key and it works fine.我用访问密钥测试了你的代码,它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.