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.
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:
query Login($email: String!, $password: String!) {
EnjinOauth(email: $email, password: $password) {
id
name
accessTokens
}
}
First, you will need to caquire your secret key, which you can do by following this query:
query GetAppSecret($id: Int!) {
EnjinApps(id: $id){
secret
}
}
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:
query RetrieveAppAccessToken($appId: Int!, $appSecret: String!) {
AuthApp(id: $appId, secret: $appSecret) {
accessToken
expiresIn
}
}
Note: Access tokens expire after 24 hours!
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.
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.
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:
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.