Skip to content

Commit

Permalink
Add possibility to get id_token or server_auth_code after login (#10)
Browse files Browse the repository at this point in the history
* Add possibility to get id_token or server_auth_code after login
  • Loading branch information
Filazapovich authored and britzl committed Sep 20, 2019
1 parent ae8650b commit 0c614dc
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 151 deletions.
41 changes: 41 additions & 0 deletions docs/_data/api.yml
Expand Up @@ -29,6 +29,7 @@

[icon:attention] By default login methods request `GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN`.
But if you use Disk, we have to request extra scope `Drive.SCOPE_APPFOLDER`.
Or if you use ID token, we have to request ID token with provided client_id.
If so it causes the first time silent sign-in to fail, except for users who
have already signed in successfully on a different device. Turn off GPGS
features you don't want to use in `game.project`.
Expand Down Expand Up @@ -95,6 +96,46 @@
end
```
#*****************************************************************************************************

- name: get_id_token
type: function
desc: Get the current GPGS player id token. Available only if "gpgs.client_id" is configured in game.project
and "gpgs.request_id_token = 1".

returns:
- name: id_token
type: string
desc: The player ID token.

examples:
- desc: |-
```lua
if gpgs then
local id_token = gpgs.get_id_token()
end
```
#*****************************************************************************************************

- name: get_server_auth_code
type: function
desc: Get the current GPGS player id token. Available only if "gpgs.client_id" is configured in game.project
and "gpgs.request_server_auth_code = 1".

returns:
- name: server_auth_code
type: string
desc: The server auth code for logged in account.

examples:
- desc: |-
```lua
if gpgs then
local server_auth_code = gpgs.get_server_auth_code()
end
```
#*****************************************************************************************************

- name: is_logged_in
Expand Down
5 changes: 5 additions & 0 deletions game.project
Expand Up @@ -21,13 +21,18 @@ shared_state = 1

[android]
package = com.potatojam.onet_paradise.match_two_tiles
minimum_sdk_version = 16
target_sdk_version = 28

[ios]
bundle_identifier = com.defoldtest.gpgs

[gpgs]
app_id = 567627510591
#client_id = client id from google console
use_saved_games = 1
request_server_auth_code = 0
request_id_token = 0

[library]
include_dirs = gpgs
41 changes: 41 additions & 0 deletions gpgs/api/gpg.script_api
Expand Up @@ -29,6 +29,7 @@

[icon:attention] By default login methods request `GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN`.
But if you use Disk, we have to request extra scope `Drive.SCOPE_APPFOLDER`.
Or if you use ID token, we have to request ID token with provided client_id.
If so it causes the first time silent sign-in to fail, except for users who
have already signed in successfully on a different device. Turn off GPGS
features you don't want to use in `game.project`.
Expand Down Expand Up @@ -95,6 +96,46 @@
end
```

#*****************************************************************************************************

- name: get_id_token
type: function
desc: Get the current GPGS player id token. Available only if "gpgs.client_id" is configured in game.project
and "gpgs.request_id_token = 1".

returns:
- name: id_token
type: string
desc: The player ID token.

examples:
- desc: |-
```lua
if gpgs then
local id_token = gpgs.get_id_token()
end
```

#*****************************************************************************************************

- name: get_server_auth_code
type: function
desc: Get the current GPGS player id token. Available only if "gpgs.client_id" is configured in game.project
and "gpgs.request_server_auth_code = 1".

returns:
- name: server_auth_code
type: string
desc: The server auth code for logged in account.

examples:
- desc: |-
```lua
if gpgs then
local server_auth_code = gpgs.get_server_auth_code()
end
```

#*****************************************************************************************************

- name: is_logged_in
Expand Down

0 comments on commit 0c614dc

Please sign in to comment.