コード例 #1
0
ファイル: LoginMgr.cs プロジェクト: leechangho12/login
    void OnClickGuestLogin()
    {
        LocalDataMgr.myLoginData.loginType = LoginType.Guest;

        if (RegUtil.Read_String("user_id", ref LocalDataMgr.myLoginData.user_id))
        {
            RegUtil.Read_String("user_token", ref LocalDataMgr.myLoginData.user_token);
            RegUtil.Read_String("email", ref LocalDataMgr.myLoginData.email);
            int _loginType = 0;
            RegUtil.Read_Int("LoginType", ref _loginType);
            LocalDataMgr.myLoginData.loginType = (LoginType)_loginType;
        }
        else
        {
            WebPktSend.Send_WebReq_101_Guest();

            RegUtil.Write_String("user_id", LocalDataMgr.myLoginData.user_id);
            RegUtil.Write_String("user_token", LocalDataMgr.myLoginData.user_token);
            RegUtil.Write_String("email", LocalDataMgr.myLoginData.email);
            RegUtil.Write_Int("LoginType", (int)LocalDataMgr.myLoginData.loginType);
        }
    }
コード例 #2
0
    // 구글에 로그인하기
    private void GoogleAuth()
    {
        if (PlayGamesPlatform.Instance.localUser.authenticated == false)
        {
            Social.localUser.Authenticate(success =>
            {
                if (success == false)
                {
                    LogText.text = "구글 로그인 실패";
                    Debug.Log("구글 로그인 실패");
                    return;
                }

                //// 로그인이 성공되었습니다.
                //{

                //    string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
                //    string clientid = "209464208604-3oo3d91mu1u6p8u6drjci36vg7jpmv5q.apps.googleusercontent.com";
                //    string secret = PlayGamesPlatform.Instance.GetServerAuthCode();
                //    string redirectURI = PlayGamesPlatform.Instance.GetServerAuthCode();

                //    var request = (HttpWebRequest)WebRequest.Create("https://accounts.google.com/o/oauth2/token");

                //    string postData = string.Format("code={0}&client_id={1}&client_secret={2}&redirect_uri={3}&grant_type=authorization_code", authCode, clientid, secret, redirectURI);
                //    var data = Encoding.ASCII.GetBytes(postData);

                //    request.Method = "POST";
                //    request.ContentType = "application/x-www-form-urlencoded";
                //    request.ContentLength = data.Length;

                //    using (var stream = request.GetRequestStream())
                //    {
                //        stream.Write(data, 0, data.Length);
                //    }

                //    var response = (HttpWebResponse)request.GetResponse();

                //    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                //    Debug.Log(responseString);

                //}

                WebPktSend.Send_WeReq_102_GooGleLogin(Social.localUser.id, PlayGamesPlatform.Instance.GetIdToken(), ((PlayGamesLocalUser)Social.localUser).Email);

                string info;
                info = "GetIdToken - " + PlayGamesPlatform.Instance.GetIdToken() + "\n" +
                       "Email - " + ((PlayGamesLocalUser)Social.localUser).Email + "\n" +
                       "GoogleId - " + Social.localUser.id + "\n" +
                       "UserName - " + Social.localUser.userName + "\n" +
                       "UserName - " + PlayGamesPlatform.Instance.GetUserDisplayName();

                LogText.text = info;
                Debug.Log("GetIdToken - " + PlayGamesPlatform.Instance.GetIdToken());
                Debug.Log("Email - " + ((PlayGamesLocalUser)Social.localUser).Email);
                Debug.Log("GoogleId - " + Social.localUser.id);
                Debug.Log("UserName - " + Social.localUser.userName);
                Debug.Log("UserName - " + PlayGamesPlatform.Instance.GetUserDisplayName());
                Debug.Log("test - " + PlayGamesPlatform.Instance.GetServerAuthCode());
            });
        }
    }