Access
Connect cross-platform accounts & identity management
You can use the AccelByte Golang SDK to implement our backend services within your game. The SDK acts as a bridge between your game and our services. Follow the tutorials below to learn how to set up our Golang SDK.
To install the AccelByte Golang SDK into your project directory, follow these steps:
Import the AccelByte Golang SDK (opens new window) into the go.mod file directly from the GitHub repository by running the following command in the terminal. Make sure to use the latest version of our Golang SDK.
go get github.com/AccelByte/accelbyte-go-sdk
Then run this command in the Terminal.
$ go mod tidy
Open the go.mod file and it will look like this.
module aws-lambda-functions
go 1.16
require (
github.com/AccelByte/accelbyte-go-sdk latest
)
To log in as the client you created earlier, follow these steps:
Create empty structs for TokenRepositoryImpl and ConfigRepositoryImpl that will be used for the following actions:
The TokenRepositoryImpl struct is used to store, get, and remove tokens.
type TokenRepositoryImpl struct {}
func (t *TokenRepositoryImpl) Store(accessToken iamclientmodels.OauthmodelTokenResponseV3) error {
clientTokenV3 = accessToken
return nil
}
func (t *TokenRepositoryImpl) GetToken() (*iamclientmodels.OauthmodelTokenResponseV3, error) {
return &clientTokenV3, nil
}
func (t *TokenRepositoryImpl) RemoveToken() error {
return nil
}
The TokenRepositoryImpl struct to get the Client ID and Client Secret.
type ConfigRepositoryImpl struct {}
func (c *ConfigRepositoryImpl) GetClientId() string {
return os.Getenv("APP_CLIENT_ID")
}
func (c *ConfigRepositoryImpl) GetClientSecret() string {
return os.Getenv("APP_CLIENT_SECRET")
}
func (c *ConfigRepositoryImpl) GetJusticeBaseUrl() string {
return os.Getenv("ACCELBYTE_BASE_URL")
}
Initialize the service SDK.
oauthService := service.OauthService{
IamService: factory.NewIamClient(&repository.ConfigRepositoryImpl{}),
ConfigRepository: &repository.ConfigRepositoryImpl{},
TokenRepository: &repository.TokenRepositoryImpl{},
}
Call the GrantTokenCredentials wrapper.
err := oauthService.GrantTokenCredentials("", "")
if err != nil {
return err
}
return nil
This wrapper provides a straightforward way to retrieve client credentials.
param := &o_auth2_0.TokenGrantV3Params{
Code: &code,
CodeVerifier: &codeVerifier,
GrantType: "client_credentials",
}
accessToken, _, _, _, err :=
oauthService.IamService.OAuth20.TokenGrantV3(param, client.BasicAuth(clientId, clientSecret))
if err != nil {
return err
}
return nil
Now you’re ready to integrate any of the following AccelByte services into your application. All services have already been imported in .../pkg/service.<your-service>
will be changed to the service name you want to use automatically during the import.
See our Golang SDK example repo (opens new window) for a selection of test cases you can use to customize your game.
SDK Reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/iam-sdk/pkg/iamclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/basic-sdk/pkg/basicclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/social-sdk/pkg/socialclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/platform-sdk/pkg/platformclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/group-sdk/pkg/groupclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/cloudsave-sdk/pkg/cloudsaveclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/dsmc-sdk/pkg/dsmcclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/sessionbrowser-sdk/pkg/sessionbrowserclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/lobby-sdk/pkg/lobbyclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/achievement-sdk/pkg/achievementclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/dslogmanager-sdk/pkg/dslogmanagerclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/ugc-sdk/pkg/ugcclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/leaderboard-sdk/pkg/leaderboardclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/gdpr-sdk/pkg/gdprclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/legal-sdk/pkg/legalclientmodels"
)
SDK reference (opens new window)
import (
"github.com/AccelByte/accelbyte-go-sdk/matchmaking-sdk/pkg/matchmakingclientmodels"
)