unsplash-js: Error trying to call public methods

Steps to Reproduce

  1. Initialize unsplash object.
  2. Call public method

Observed Behaviour

Server response with 401: “OAuth error: The access token is invalid”:

image

image

Technical Notes

As I read in unslplash docs, if you want to access only to public methods, you don’t need to use oauth. Instead, you have to use special headers providing your access key.

Authorization: Client-ID YOUR_ACCESS_KEY

But here we are using APPLICATION_ID instead ACCESS_KEY in the header: https://github.com/unsplash/unsplash-js/blob/master/src/utils/index.js#L32

I’m going to prepare a PR in order to fix this.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 25 (5 by maintainers)

Most upvoted comments

Fixed! Simply call the API via the link below and input the access key provided as the client_id and query as whatever you’re searching for. “https://api.unsplash.com/photos/(client_id=access key)?query=house”

For example, after registering your app on unsplash. You were given: Access Key : 64bde1bec62d51bcbb8eeb047652

To use the key above to search for pictures of houses, simply use the api like this: https://api.unsplash.com/photos/client_id=64bde1bec62d51bcbb8eeb047652?query=house

I hope this helps.

This error also occurred due to the typo of the header instead headers. Make sure You define headers

Still broken 🤕

this is still broken

Im facing same problem here

I’m getting this same issue. I take the Access token that I’m given from unsplash and plug it in here - https://api.unsplash.com/search/photos/?client_id=(ACCESS_TOKEN)?query=cars

Yeah I was looking at that too.