Hyper OAuth
Use Hyper OAuth to authenticate users in your application.
Prerequisites
- Create a Hyper account
- Connect Stripe
- Generate a Publishable API key here
The Hyper OAuth flow allows you to customize the user's experience and abstract Hyper's functionality entirely. The following guide will introduce you to the basic OAuth flow and give examples of how to interact with our API.
Authorizing a user into your application using Hyper OAuth is simple.
Build your OAuth URL
Building your OAuth URL is simple — all you'll need is your Hyper member portal URL. If you're not sure what it is, you can copy it from the "Visit Portal" button on the home page of the dashboard. Once you have the portal URL, you'll want to append /oauth/authorize
to the URL.
-
Choosing a grant type
Grant types are simple: you can choose from
license
which will return the string representing a user's license key (if any), oruser
which will return their Hyper user ID. Either can be used,user
is preferable if your users may have multiple licenses on your account. -
Set a redirect URI
Setting a redirect URI lets Hyper know where to send your user after they complete authenticating on our end. Most times, this will be a redirect to a page in your application or API. Once the user logs in or authorizes the designated provider, they'll be sent here with the specified query parameters.
-
Choose a method
At this time, the only method you can pass is
discord
. If passed, this query parameter will redirect the user directly to this method's OAuth provider, instead of sending the user to your Hyper member portal. If you setmethod
to Discord, the first screen the user will see is Discord OAuth. -
Putting it all together
Once you've collected your Portal URL, grant type, redirect URI, and optionally method, it's time to put all three together. Here's what our Developers account OAuth URL looks like. We'll use
https://api.connorstevens.dev
as our example API to call-back to.
Where https://dev.hyper.co/oauth/authorize
is our Portal URL, user
is our grant type, and https://api.connorstevens.dev/callback
is our Redirect URI.
Once a user completes this flow, you can interact with the Hyper API and authenticate the user into your application.
Retrieve a user's license(s)
If you've chosen the license
grant_type, you can access the license
query parameter from the request to get the user's license key. Using either a publishable or secret API key, you can retrieve the license, example here. If the API returns a license with a status that is not active
or trialing
, it's safe to assume the user does not have access to your application.
Otherwise, if you've chosen the user
query parameter, you'll want to have a Secret API key on hand. If you don't have one already, you can request one here. You can access the user
query parameter from the request, and then use the list licenses endpoint and set `?user= as a query parameter.
Allow access to your application
Once you've validated that a user has an active license to your application, you can let them in!
If you have any questions, please open a ticket in our Discord server
Updated 5 months ago