public static void LoginUserWithGameCenterId(string id, Action <bool> callback)
        {
            string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("gamecenter|" + id));

            Dictionary <string, string> body = new Dictionary <string, string>();

            body.Add("Authorization", auth);
            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.post("/account/login", JsonMapper.ToJson(body), auth, null, null,
                                      delegate(bool success, object data) {
                if (success)
                {
                    sessionToken = JsonMapper.ToObject <GDSessionToken>((string)data);
                    PlayerPrefs.SetString("gd_session_token", sessionToken.session_token);
                    RegisterDeviceAfterLogin(callback);
                }
                else
                {
                    if (callback != null)
                    {
                        callback(success);
                    }
                }
            }
                                      )
                );
        }
        public static void LoginUserWithSessionToken(Action <bool> callback)
        {
            string session_token = PlayerPrefs.GetString("gd_session_token");

            if (session_token != null && session_token.Length > 0)
            {
                string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("session_token|" + session_token));

                Dictionary <string, string> body = new Dictionary <string, string> ();
                body.Add(GamedoniaRequest.GD_AUTH, auth);
                GamedoniaBackend.RunCoroutine(
                    GamedoniaRequest.post("/account/login", JsonMapper.ToJson(body), auth, null, null,
                                          delegate(bool success, object data) {
                    if (success)
                    {
                        sessionToken = JsonMapper.ToObject <GDSessionToken> ((string)data);
                        RegisterDeviceAfterLogin(callback);
                    }
                    else
                    {
                        if (callback != null)
                        {
                            callback(success);
                        }
                    }
                }
                                          )
                    );
            }
            else
            {
                Debug.LogWarning("No sessionToken stored in PlayerPrefs");
                if (callback != null)
                {
                    callback(false);
                }
            }
        }
Beispiel #3
0
        public static void LoginUserWithTwitter(string twuid, string twTokenSecret, string twToken, Action<bool> callback)
        {
            string auth = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("twitter|" + twuid + "|" + twTokenSecret + "|" + twToken));

            Dictionary<string,string> body = new Dictionary<string, string>();
            body.Add(GamedoniaRequest.GD_AUTH,auth);
            GamedoniaBackend.RunCoroutine(
                GamedoniaRequest.post("/account/login",JsonMapper.ToJson(body),auth,null,null,
                    delegate (bool success, object data) {
                        if (success) {
                            sessionToken = JsonMapper.ToObject<GDSessionToken>((string)data);
                            PlayerPrefs.SetString("gd_session_token", sessionToken.session_token);
                            RegisterDeviceAfterLogin(callback);
                        }else {
                            if (callback != null) callback(success);
                        }
                    }
             	 )
            );
        }
Beispiel #4
0
        public static void LoginUserWithSessionToken(Action<bool> callback)
        {
            string session_token = PlayerPrefs.GetString("gd_session_token");
            if (session_token != null && session_token.Length > 0) {
                string auth = System.Convert.ToBase64String (Encoding.UTF8.GetBytes ("session_token|" + session_token));

                Dictionary<string,string> body = new Dictionary<string, string> ();
                body.Add (GamedoniaRequest.GD_AUTH, auth);
                GamedoniaBackend.RunCoroutine (
                GamedoniaRequest.post ("/account/login", JsonMapper.ToJson (body), auth, null, null,
                    delegate (bool success, object data) {
                                if (success) {
                                        sessionToken = JsonMapper.ToObject<GDSessionToken> ((string)data);
                                        RegisterDeviceAfterLogin (callback);
                                } else {
                                        if (callback != null)
                                                callback (success);
                                }
                        }
                    )
                );
            } else {
                Debug.LogWarning("No sessionToken stored in PlayerPrefs");
                if (callback!=null) callback(false);
            }
        }