A noob trying to understand how to connect to the API

Hey guys!

I’m sitting here waiting for my reviews to come up and decided to start playing around with the API. I’ve only recently (a month ago) started learning how to connect to API’s and doing all the cool stuff that you can do with them. I’m currently trying to connect to my account using my API v2 key via the request node package.

When I try connecting, I keep getting a 401 error, and I figure it’s that I’m making a simple mistake when writing the header. The code is as follows:

let options = {
   url: 'https://api.wanikani.com/v2/user',
   headers: {'Authorization': '{API Key goes here}'}

request(options, function(error, response, body){

I’m certain I’m just not understanding the documentation on how I need to set this up.
Thanks in advance. <3

Of course as SOON as I post this, I figure it out. That always happens.
I didn’t know that I had to actually put ‘Bearer {API Key}’.

Any particular reason why 'Bearer ’ needs to be in front of the key?

The Authorization header has been used for multiple purposes, where the first word denotes the type. There’s typically support for “basic” and “digest” authentication built in to browsers. IIRC the “bearer” authentication type was defined for OAuth usage, but it could be used by any token-based authentication system.

Ahhhh, I see now with how it has the other types listed. Thanks for the explanation! :smiley: