Learn more about using Oneloop NextJS SDK
auth
higher order function to your route handler.
First you create a oneloop client using ‘createOneloop’ function and pass in your Oneloop SDK key to it.
Then you pass this client to the auth
higher order function.
This function will automatically verify the user’s API key and return a 401 if the key is invalid. To override this behavior, you can pass in a custom error handlers as the third argument as shown here
scopes
property to the auth
function.
Scopes takes in an array of objects with the representation
and optional read
, create
, update
, and del
properties.
So to check if the key has read and create access attached to profile scope, we can modify our code as below
auth
function for handling errors and invalid keys.
There are 2 types of handlers you can pass in: onError
and onInvalidKey
.
onInvalidKey()
onError()