Get started with Extend SDK sample CLI app
Overview
The AccelByte Extend SDK is provided to help developers invoke AccelByte Gaming Services (AGS) endpoints from within their backend code, or other automation such as CI/CD pipelines. Extend SDK sample CLI application is a sample command line application to interact with AccelByte Extend SDK. You can use it as it is or use it as a reference for your own application.
Goals
In this guide you will:
- Download Extend SDK sample CLI app.
- Build the application.
- Run the application.
Prerequisites
In order to start on this guide, you should have:
- C#
- Go
- Java
- Python
- Access to the AccelByte Gaming Services (AGS) (demo environment):
- Use
<your environment's domain URL>
forAB_BASE_URL
environment variable.- Example for AGS Shared Cloud customer:
https://spaceshooter.prod.gamingservices.accelbyte.io
- Example for AGS Private Cloud customer:
https://dev.customer.accelbyte.io
- Example for AGS Shared Cloud customer:
- Create an Oauth Client with client type Confidential.
- Use Client ID value for
AB_CLIENT_ID
environment variable. - Use Client Secret value for
AB_CLIENT_SECRET
environment variable.
- Use Client ID value for
- Use
- AccelByte C# Extend SDK
- Access to the following tools:
- Git
- .NET SDK 6.0
- C# IDE
- Access to the AccelByte Gaming Services (AGS) (demo environment):
- Use
<your environment's domain URL>
forAB_BASE_URL
environment variable.- Example for AGS Shared Cloud customer:
https://spaceshooter.prod.gamingservices.accelbyte.io
- Example for AGS Private Cloud customer:
https://dev.customer.accelbyte.io
- Example for AGS Shared Cloud customer:
- Create an Oauth Client with client type Confidential.
- Use Client ID value for
AB_CLIENT_ID
environment variable. - Use Client Secret value for
AB_CLIENT_SECRET
environment variable.
- Use Client ID value for
- Use
- AccelByte Go Extend SDK
- Access to the following tools:
- Git
- Go 1.18 or later
- Go IDE
- Access to the AccelByte Gaming Services (AGS) (demo environment):
- Use
<your environment's domain URL>
forAB_BASE_URL
environment variable.- Example for AGS Shared Cloud customer:
https://spaceshooter.prod.gamingservices.accelbyte.io
- Example for AGS Private Cloud customer:
https://dev.customer.accelbyte.io
- Example for AGS Shared Cloud customer:
- Create an Oauth Client with client type Confidential.
- Use Client ID value for
AB_CLIENT_ID
environment variable. - Use Client Secret value for
AB_CLIENT_SECRET
environment variable.
- Use Client ID value for
- Use
- AccelByte Java Extend SDK
- Access to the following tools:
- Git
- Java Development Kit (JDK) 8
- Gradle 7
- Java IDE
- Access to the AccelByte Gaming Services (AGS) (demo environment):
- Use
<your environment's domain URL>
forAB_BASE_URL
environment variable.- Example for AGS Shared Cloud customer:
https://spaceshooter.prod.gamingservices.accelbyte.io
- Example for AGS Private Cloud customer:
https://dev.customer.accelbyte.io
- Example for AGS Shared Cloud customer:
- Create an OAuth Client with client type Confidential.
- Use Client ID value for
AB_CLIENT_ID
environment variable. - Use Client Secret value for
AB_CLIENT_SECRET
environment variable.
- Use Client ID value for
- Use
- AccelByte Python Extend SDK
- Access to the following tools:
- Git
- Python 3.10
- Python IDE
Build CLI sample app
- C#
- Go
- Java
- Python
- Pull AccelByte C# Extend SDK repository.
- Go to
samples/AccelByte.Sdk.Sample.Cli
. - Run
dotnet build
to build the application.
- Pull AccelByte Go Extend SDK repository.
- Go to
samples/cli
. - Run
go build
to build the application.
- Pull AccelByte Java Extend SDK repository.
- Go to
samples/cli
. - Run
bash gradlew installDist
to build the application.
- Pull AccelByte Python Extend SDK repository.
- Go to
samples/cli
.
Python can use python command line directly without building the app.
Using CLI sample app
Set up environment variables
You have to declare these environment variables below:
AB_BASE_URL
(required)
AB_CLIENT_ID
(required)
AB_CLIENT_SECRET
(required for private OAuth client only)
- Linux
- Windows
- macOS
export AB_CLIENT_ID=<value>
export AB_CLIENT_SECRET=<value>
export AB_BASE_URL="https://<environment>.accelbyte.io"
# To check if you use the correct value
echo AB_CLIENT_ID
echo $AB_CLIENT_SECRET
echo $AB_BASE_URL
setx AB_CLIENT_ID "<value>"
setx AB_CLIENT_SECRET "<value>"
setx AB_BASE_URL "https://<environment>.accelbyte.io"
# To check if you use the correct value
echo %AB_CLIENT_ID%
echo %AB_CLIENT_SECRET%
echo %AB_BASE_URL%
export AB_CLIENT_ID=<value>
export AB_CLIENT_SECRET=<value>
export AB_BASE_URL="https://<environment>.accelbyte.io"
# To check if you use the correct value
echo AB_CLIENT_ID
echo $AB_CLIENT_SECRET
echo $AB_BASE_URL
- C#
- Go
- Java
- Python
Use the CLI sample app
To login:
AccelByte.Sdk.Sample.Cli.exe --op login --user <username> --pass <password>
For client type login (environment var
AB_CLIENT_SECRET
is required), use this command:AccelByte.Sdk.Sample.Cli.exe --op login --lt client
After successful login, then you can execute available commands, for example:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --op <operation_name> --namespace <namespace_name>
For any operation that requires request body:
Use json file as request body:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --op <operation_name> --namespace <namespace_name> --reqfile "<path_to_json_file>"
or use json string as request body:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --op <operation_name> --namespace <namespace_name> --reqbody "<json_content>"
dangerUse either
--reqfile
or--reqbody
to set request body. Do not use both of them at the same time.For any operation that requires a file to be uploaded:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --op <operation_name> --namespace <namespace_name> --upload "<path_to_file>"
To shows usage help:
AccelByte.Sdk.Sample.Cli.exe
Listen to web socket service:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --ws --ws-listen
danger--ws-listen
argument cannot be mixed with--interactive
,--ws-payload
, or--ws-payload-file
.Sending web socket message:
Use json file as payload:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --ws --ws-payload-file <path_to_json_file>
or use json string as payload:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --ws --ws-payload "<json_content>"
dangerUse either
--ws-payload
or--ws-payload-file
. Do not use both of them at the same time. Also do not use these together with either--ws-listen
and/or--interactive
.Use interactive mode to send web socket message:
AccelByte.Sdk.Sample.Cli.exe --sn <service_name> --ws --interactive
danger--interactive
argument cannot be mixed with--ws-listen
,--ws-payload
, or--ws-payload-file
.
In linux, the resulting executable filename should be AccelByte.Sdk.Sample.Cli
.
Please read CLI sample app README for more detailed information.
commands
sample-apps <command> [options]
To see available service commands (HTTP endpoints):
sample-apps -h
To see available endpoint of a service command (HTTP endpoints):
sample-apps <ServiceName-command> -h
To see available options of a specific command (HTTP endpoints):
sample-apps <ServiceName-command> <methodName-command> -h
To enter WebSocket mode (WebSocket endpoints):
sample-apps --wsMode
Most commands will require you to login as either a client
or as a user
.
For these commands you'll have to pass either sample-apps login
or sample-apps loginClient
.
# Login as user
sample-apps login -u admin+omega@accelbyte.net -p S8i9wfIQrV8oQ7gRSQokh2Xn1g7bOhoP
# Note: Please specify clientId and clientSecret in configRepository. Please refer to `sample-apps/pkg/repository`
# LoginClient as client
sample-apps loginClient
# Note: oauth token with client_credentials grant type
Examples
Interacting with Justice HTTP Endpoints
Note: Please do login
# Register User
sample-apps Iam publicCreateUserV3 --namespace 'accelbyte' --body '{"PasswordMD5Sum": "string", "acceptedPolicies": [{"isAccepted": true, "localizedPolicyVersionId": "string", "policyId": "string", "policyVersionId": "string"}], "authType": "EMAILPASSWD", "code": "GWUvzq1Z", "country": "US", "dateOfBirth": "2019-04-29", "displayName": "goSDK", "emailAddress": "goSDK@accelbyte.net", "password": "password1", "reachMinimumAge": false}'
# Get user roles
sample-apps Iam adminGetRolesV3 --after '' --before '' --limit '20' --isWildcard 'False'
# Get my profile
sample-apps Basic getMyProfileInfo --namespace 'accelbyte'
# Verify Token
sample-apps Iam publicUserVerificationV3 --namespace accelbyte --body '{"code":"123456","contactType":"string","languageTag":"en-US","validateOnly":true}'
# Get Store Items
sample-apps Platform queryItems --namespace 'accelbyte' --activeOnly 'False' --appType 'GAME' --itemType 'INGAMEITEM' --limit '20' --offset '0' --availableDate 'string' --baseAppId 'string' --categoryPath 'string' --features 'string' --region 'string' --sortBy 'string' --storeId 'string' --tags 'string' --targetNamespace 'string'
# Entitlements
sample-apps Platform grantEntitlement --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539' --body '[{"endDate": "1975-11-20T00:00:00Z", "grantedCode": "string", "itemId": "string", "itemNamespace": "string", "language": "string", "quantity": 64, "region": "string", "source": "REFERRAL_BONUS", "startDate": "1995-03-07T00:00:00Z", "storeId": "string"}]'
sample-apps Platform getUserEntitlement --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539' --entitlementId 'string'
# Friends
sample-apps Lobby addFriendsWithoutConfirmation --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539' --body '{"friendIds": ["e5ca182435a84802b4996b6bdbeffa85"]}'
sample-apps Lobby getListOfFriends --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539'
# Game records
sample-apps Cloudsave postGameRecordHandlerV1 --namespace 'accelbyte' --key 'sample-key' --body '{"key1": "value1"}'
sample-apps Cloudsave getGameRecordHandlerV1 --namespace 'accelbyte' --key 'sample-key'
# Player records
sample-apps Cloudsave postPlayerPublicRecordHandlerV1 --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539' --key 'sample-key' --body '{"key1":"value1"}'
sample-apps Cloudsave getPlayerPublicRecordHandlerV1 --namespace 'accelbyte' --userId 'd34a444f173f4ed49e44bd9f22418539' --key 'sample-key'
# Note: make user ID player registered on specified namespace
Interacting with Justice WebSocket Endpoints
Perform login and enter websocket mode.
Example:
## Login using existing user
sample-apps login -u admin+omega@accelbyte.net -p S8i9wfIQrV8oQ7gRSQokh2Xn1g7bOhoP
## Enter ws mode, if successfully connected, menu option will appears and sample-apps will listen for user input.
sample-apps --wsMode
Please read CLI sample app README for more detailed information.
Login
Before calling any service endpoints, perform login first. Your access token will be saved and it will be used to call service endpoints.
build/install/cli/bin/cli login -u myUsername -p myPassword
Calling a Service Endpoint
To call a service endpoint, the CLI command structure is shown below.
build/install/cli/bin/cli <service name> <operation> --<parameter> <parameter value>
For example:
build/install/cli/bin/cli basic publicGetCountries --namespace accelbyte
Help
To see general help:
build/install/cli/bin/cli -h
To see specific help for iam
service:
build/install/cli/bin/cli iam -h
Please read CLI sample app README for more detailed information.
Use the CLI sample app
$ python -m accelbyte_py_sdk_cli --help
Usage: python -m accelbyte_py_sdk_cli [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
...
iam-auth-code-request-v3
iam-authorization
iam-authorize-v3
iam-ban-user
iam-create-client
iam-create-client-by-namespace
iam-create-role
iam-disable-user
iam-disable-user-ban
iam-enable-user
iam-enable-user-ban
iam-forgot-password
iam-get-bans-type
iam-get-client
iam-get-clients
iam-get-country-location-v3
iam-get-jwks
iam-get-jwksv3
iam-get-list-ban-reason
iam-get-user-ban-history
iam-get-user-by-login-id
iam-get-user-by-platform-user-id
iam-get-user-by-user-id
iam-get-user-information
iam-get-user-platform-accounts
iam-get-user-verification-code
iam-get-users-by-login-ids
...
You can get more information for each command by using this syntax:
$ python -m accelbyte_py_sdk_cli COMMAND --help
$ python3 -m accelbyte_py_sdk_cli iam-get-bans-type --help
Usage: python -m accelbyte_py_sdk_cli iam-get-bans-type [OPTIONS]
Options:
--login_as [client|user]
--help Show this message and exit.
Most commands will require you to login as either a client
or as a user
.
For these commands you'll have to pass either --login_as client
or --login_as user
.
Examples
Usage: python -m accelbyte_py_sdk_cli iam-get-bans-type [OPTIONS]
Options:
--login_as [client|user]
--help Show this message and exit.
$ python -m accelbyte_py_sdk_cli iam-get-bans-type --login_as user
GetBansType success success
Usage: python -m accelbyte_py_sdk_cli iam-public-create-user-v3 [OPTIONS] DISPLAY_NAME EMAIL_ADDRESS
DATE_OF_BIRTH COUNTRY PASSWORD
Options:
--namespace TEXT
--role_id TEXT
--login_as [client|user]
--help Show this message and exit.
$ python -m accelbyte_py_sdk_cli iam-public-create-user-v3 eagerhamster6800 vi7xUuNc4j@fakemail.com 2000-09-23 US "****" --login_as client
PublicCreateUserV3 success
Usage: python -m accelbyte_py_sdk_cli iam-admin-get-my-user-v3 [OPTIONS]
Options:
--login_as [client|user]
--help Show this message and exit.
$ python -m accelbyte_py_sdk_cli iam-admin-get-my-user-v3 --login_as user
AdminGetMyUserV3 success
Usage: python -m accelbyte_py_sdk_cli iam-admin-update-client-v3 [OPTIONS] CLIENT_ID
CLIENT_UPDATE_REQUEST
Options:
--namespace TEXT
--login_as [client|user]
--help Show this message and exit.
$ python -m accelbyte_py_sdk_cli iam-admin-update-client-v3 **** {"clientName": "****"} --login_as user
AdminUpdateClientV3 success
Usage: python -m accelbyte_py_sdk_cli iam-admin-update-user-v3 [OPTIONS] USER_ID
Options:
--country TEXT
--date_of_birth TEXT
--display_name TEXT
--language_tag TEXT
--user_name TEXT
--namespace TEXT
--login_as [client|user]
--help Show this message and exit.
$ python -m accelbyte_py_sdk_cli iam-admin-update-user-v3 **** --date_of_birth 2000-09-23 --login_as user
AdminUpdateUserV3 success
Please read CLI sample app README for more detailed information.