Extend SDK sample CLI app
Overview
The Extend SDK sample CLI app is a command-line application provided to developers as a reference for using the AccelByte Extend SDK. It demonstrates how to implement the SDK in your own projects and is available in several selected programming languages, just like the SDK itself.
Goals
- Build the sample CLI app from source
- Use the sample CLI app to call AccelByte Gaming Services (AGS) endpoints
Prerequisites
- C#
- Go
- Java
- Python
- Access to the AccelByte Gaming Services (AGS):
- 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
- Access to the following tools:
- Git
- .NET SDK 6.0
- C# IDE
- Access to the AccelByte Gaming Services (AGS):
- 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
- Access to the following tools:
- Git
- Go 1.18 or later
- Go IDE
- Access to the AccelByte Gaming Services (AGS):
- 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
- Access to the following tools:
- Git
- Java Development Kit (JDK) 8
- Gradle 7
- Java IDE
- Access to the AccelByte Gaming Services (AGS):
- 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
- Access to the following tools:
- Git
- Python 3.10
- Python IDE
Building
- C#
- Go
- Java
- Python
- Clone the AccelByte C# Extend SDK repository.
- Go to
samples/AccelByte.Sdk.Sample.Cli
. - Run
dotnet build
to build the application.
- Clone the AccelByte Go Extend SDK repository.
- Go to
samples/cli
. - Run
go build
to build the application.
- Clone the AccelByte Java Extend SDK repository.
- Go to
samples/cli
. - Run
bash gradlew installDist
to build the application.
- Clone the AccelByte Python Extend SDK repository.
- Go to
samples/cli
.
The Python version does not need to be built and it can be executed directly.
Usage
Setting up
- Linux
- Windows
- macOS
export AB_BASE_URL="https://<environment>.accelbyte.io"
export AB_CLIENT_ID=<value>
export AB_CLIENT_SECRET=<value>
# For Python Extend SDK sample CLI app only (--login-as user)
export AB_USERNAME=<value>
export AB_PASSWORD=<value>
setx AB_BASE_URL "https://<environment>.accelbyte.io"
setx AB_CLIENT_ID "<value>"
setx AB_CLIENT_SECRET "<value>"
rem For Python Extend SDK sample CLI app only (--login-as user)
setx AB_USERNAME "<value>"
setx AB_PASSWORD "<value>"
export AB_BASE_URL="https://<environment>.accelbyte.io"
export AB_CLIENT_ID=<value>
export AB_CLIENT_SECRET=<value>
# For Python Extend SDK sample CLI app only (--login-as user)
export AB_USERNAME=<value>
export AB_PASSWORD=<value>
Logging in
- C#
- Go
- Java
- Python
Login using OAuth client
AccelByte.Sdk.Sample.Cli.exe --op login --lt client
Login using username and password
AccelByte.Sdk.Sample.Cli.exe --op login --user <username> --pass <password>
Login using OAuth client
sample-apps loginClient
Login using username and password
sample-apps login -u <username> -p <password>
Login using OAuth client
build/install/cli/bin/cli loginClient
Login using username and password
build/install/cli/bin/cli login -u <username> -p <password>
Login using OAuth client
For example, calling iam-public-create-user-v3
endpoint using OAuth client (--login_as client
).
python -m accelbyte_py_sdk_cli iam-public-create-user-v3 eagerhamster6800 vi7xUuNc4j@fakemail.com 2000-09-23 US "****" --login_as client
Login using username and password
For example, calling iam-get-bans-type
endpoint using OAuth client (--login_as user
).
python -m accelbyte_py_sdk_cli iam-get-bans-type --login_as user
The Python version does not have a dedicated login command. Login is performed as we call an an endpoint.
Calling an endpoint
For example, calling IAM get country location v3 endpoint.
- C#
- Go
- Java
- Python
AccelByte.Sdk.Sample.Cli.exe --sn iam --op GetCountryLocationV3
sample-apps Iam getCountryLocationV3
build/install/cli/bin/cli iam getCountryLocationV3
python -m accelbyte_py_sdk_cli iam-get-country-location-v3 --login_as user
Help
- C#
- Go
- Java
- Python
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
See the sample CLI app README for more information.
To see general help:
build/install/cli/bin/cli -h
To see specific help for iam
service:
build/install/cli/bin/cli iam -h
See the sample CLI app README for more information.
To see general help:
$ 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
For example:
$ 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.
See the sample CLI app README for more information.