2. Configure OAuth URL
Configure your HYPLAY authorization URL for users to be able to login to your app or game with their HYPLAY account.
Step 1: Configure Your OAuth URL
Your OAuth URL for your HYPLAY application is the entry point for all users to sign in or register for your app or game with HYPLAY, and approve permissions for you to interact with assets in the wallets and perform transaction on their behalf.
For this guide, we're going to use the following URL. You'll need to modify this slightly for your application: https://hyplay.com/oauth/authorize/?appId=YOUR_APP_ID_HERE&chain=HYCHAIN_TESTNET&responseType=token&redirectUri=YOUR_REDIRECT_URI_HERE
- For
appId
replace theYOUR_APP_ID_HERE
with theid
of your created app from the following step. - For
chain
, this is the blockchain that a user using this authorization flow is approving permissions for. In this case it's HYCHAIN's testnet - which is a testing environment. For mainnet (production environment) you can useHYCHAIN
. - For
responseType
we've used a value oftoken
- this means the redirectUri will have the access token returned in the redirect as a url fragment (#
). This is also known as an implicit auth flow. - For
redirectUri
replace theYOUR_REDIRECT_URI_HERE
with a approved redirect uri you set when creating your application. This is where a user will be redirected to once completing or cancelling the flow.
You can find complete documentation on all the query parameters you can configure for your OAuth URL, here: https://docs.hyplay.com/docs/auth-url-construction#oauth-url-construction
Step 2: Test Your OAuth URL
Now it's time to test your OAuth URL! Enter it into your browser, you should see the start of the authorization flow branded with your app's icon, background image and name.
Complete the flow and you will be redirected back to the provided redirectUri. In the redirected url, you'll see an access token after the fragment (#
) in the url. Your application can parse this out of the URL to retrieve it.
If you want to quickly test the OAuth flow, you can use our demo app: https://hyplay.com/oauth/authorize/?appId=ce904287-c653-4231-87d5-3e87ab50c382&chain=HYCHAIN_TESTNET&responseType=token&redirectUri=https%3A%2F%2Fhyplay.com
Step 3: Retrieving An Auth'd User
After a user has went through your auth flow and you've retrieved their access token, you'll likely want to their details such as id
, username
, and other information.
You can quickly get the user's information with the get current user API endpoint, here: https://docs.hyplay.com/reference/getcurrentuser
Next Steps
Next up, we'll execute our first transaction as an authorized user: 3. Execute 1st Transaction
Updated 4 months ago