Skip to content

Commit e50a325

Browse files
committed
Update readme
1 parent 4e92bd7 commit e50a325

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

readme.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@ If you are building for mobile or web, you will need to create a login screen an
1919
4. In the success handler call `GameSwiftSdkId.Authorize` method, which will perform all of the next steps for you automatically. Remember to use stored `GameSwiftSdkId.Instance.CmdAccessToken` here. Also, provide your `clientId` and `redirectUri`. If the process is finished successfully you will be authorized and a new `AccessToken` will be stored in the SDK's `GameSwiftSdkId.Instance.AccessToken` field. From now on you should be using this token in each request.
2020

2121
```cs
22+
using GameSwiftSDK.Core;
23+
using GameSwiftSDK.Id;
24+
using GameSwiftSDK.Id.Responses;
25+
using UnityEngine;
26+
2227
public class GameSwiftLauncherLogin : MonoBehaviour
2328
{
29+
private const string CLIENT_ID = "yourClientId";
30+
private const string REDIRECT_URI = "yourRedirectUri";
31+
2432
private void Awake()
2533
{
2634
if (Application.isEditor == false)
@@ -62,29 +70,47 @@ In order to authorize this way, instead of instructions described in the point 4
6270
4. If the process is finished successfully you will be logged in, authorized and a new `AccessToken` will be stored in the SDK's `GameSwiftSdkId.Instance.AccessToken` field. From now on you should be using this token in each request.
6371

6472
```cs
73+
using GameSwiftSDK.Core;
74+
using GameSwiftSDK.Id;
75+
using GameSwiftSDK.Id.Responses;
76+
using TMPro;
77+
using UnityEngine;
78+
using UnityEngine.UI;
79+
6580
public class GameSwiftManualLogin : MonoBehaviour
6681
{
6782
private const string CLIENT_ID = "yourClientId";
6883
private const string REDIRECT_URI = "yourRedirectUri";
6984

7085
[SerializeField] private TMP_InputField emailOrNickname;
7186
[SerializeField] private TMP_InputField password;
87+
[SerializeField] private Button loginButton;
7288

73-
private void Awake()
89+
private void OnEnable ()
90+
{
91+
loginButton.onClick.AddListener(LoginUser);
92+
}
93+
94+
private void LoginUser ()
7495
{
7596
GameSwiftSdkId.LoginAndAuthorize(emailOrNickname.text, password.text,
7697
CLIENT_ID, REDIRECT_URI, HandleSuccess, HandleFailure);
7798
}
7899

79-
private void HandleSuccess(LoginResponse response)
100+
private void HandleSuccess (OauthUserInfoResponse response)
80101
{
81102
// your code on success login
82103
}
83104

84-
private void HandleFailure(BaseSdkFailResponse response)
105+
private void HandleFailure (BaseSdkFailResponse response)
85106
{
86107
Debug.LogError($"Login error, code: {response.statusCode}, message: {response.Message}");
87108
}
109+
110+
private void OnDisable ()
111+
{
112+
loginButton.onClick.RemoveListener(LoginUser);
113+
}
88114
}
89115
```
90116

@@ -103,7 +129,5 @@ If you don't use our recommended login approaches, remember to call `GameSwiftSd
103129
# Hello Hero
104130
Hello Hero is our sample application that shows how your game can be properly integrated with our SDK. In the aplication we can test requests to the `GameSwift ID` and we can see some basic results in the panel `Output`. Feel free to experiment with it!
105131

106-
![Endpoint](GameSwitftSDK/DocsScreenshots/HelloHero.png)
107-
108132
# Contact Us
109133

0 commit comments

Comments
 (0)