Creating Your Integration
7

Once you have minted your tokens and are comfortable with managing them, it's time to start integrating them into your project or game.

Although we have some very useful SDKs that can help you get on your feet, it's very important that all of your admin and user data is parsed and stored by a secure server.

This means, you will need solid knowledge of our Cloud API (GraphQL) to complete your secure integration.

Step 1: Getting Your Bearer Token

The first step is acquiring your bearer token. In the creating your account section, you would have logged into your account using the following query:

GraphQL
query Login($email: String!, $password: String!) {
 EnjinOauth(email: $email, password: $password) {
   id
   name
   accessTokens
 }
}

Step 2: Getting the Secret Key

First, you will need to caquire your secret key, which you can do by following this query:

GraphQL
query GetAppSecret($id: Int!) {
 EnjinApps(id: $id){
   secret
 }
}

Step 3: Getting the Access Token

SECURITY: MAKE SURE TO STORE THIS SERVERSIDE!

Once you have retrieved the app secret from the previous step, you will need the access token, which you can retrieve by following this query:

GraphQL
query RetrieveAppAccessToken($appId: Int!, $appSecret: String!) {
 AuthApp(id: $appId, secret: $appSecret) {
   accessToken
   expiresIn
 }
}

Note: Access tokens expire after 24 hours!

Step 4: Creating a User

In this step, with the access token that you retrieved in the previous step, you will need to pass that as the authorization header when performing the create user mutation.

Your authorization system needs to check to see if a user's account has been created yet.

  • If it hasn't, it should create a new account for them.
  • If it has, then the system should try to log them in.
GraphQL
mutation CreateUser($name: String!) {
 CreateEnjinUser(name: $name) {
   id
   accessTokens
   identities {
     linkingCode
     linkingCodeQr
     wallet {
       ethAddress
     }
   }
 }
}

Once you have created an Enjin account, it's advisable to enter the reference into your database, so you don't repeat this process unnecessarily in the future.

Step 5: Loggin Your User In

In this final step of integration, once you are have confirmed that your user has an existing account, you can log your user in by following this query:

GraphQL
query RetrievePlayerAccessToken($name: String!) {
 AuthPlayer(id: $name) {
   accessToken
   expiresIn
 }
}

If the API returns a linking code, that means the user's Enjin Wallet is not linked. If no linking code is returned, this means the wallet is linked and you can send the user into the game.

Previous
next
On This Page