Ejemplo n.º 1
0
 public static void AuthenticateWithItchIOToken(string jwtToken,
                                                Action <UserProfile> onSuccess,
                                                Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithItchIOToken(jwtToken, false,
                                                       onSuccess, onError);
 }
Ejemplo n.º 2
0
 public static void AuthenticateWithGOGEncryptedAppTicket(byte[] data, uint dataSize,
                                                          Action <UserProfile> onSuccess,
                                                          Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithGOGEncryptedAppTicket(data, dataSize, false,
                                                                 onSuccess, onError);
 }
Ejemplo n.º 3
0
 public static void AuthenticateWithGOGEncryptedAppTicket(string encodedTicket,
                                                          Action <UserProfile> onSuccess,
                                                          Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithGOGEncryptedAppTicket(encodedTicket, false,
                                                                 onSuccess, onError);
 }
Ejemplo n.º 4
0
 public static void AuthenticateWithXboxLiveToken(string xboxLiveUserToken,
                                                  Action <UserProfile> onSuccess,
                                                  Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithXboxLiveToken(xboxLiveUserToken, false,
                                                         onSuccess, onError);
 }
Ejemplo n.º 5
0
        /// <summary>Attempts to authenticate a user using a Steam Encrypted App Ticket.</summary>
        public static void AuthenticateWithSteamEncryptedAppTicket(string encodedTicket,
                                                                   Action <UserProfile> onSuccess,
                                                                   Action <WebRequestError> onError)
        {
            APIClient.RequestSteamAuthentication(encodedTicket, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    steamTicket      = encodedTicket,
                    gogTicket        = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                                 (e) =>
            {
                UnityEngine.Debug.LogError(
                    $"<b>[mod.io Authentication Steam]</b> Failed with ticket: {encodedTicket}"
                    + $"{System.Environment.NewLine}{e.ToUnityDebugString()}");
                onError(e);
            }
                                                 );
        }
Ejemplo n.º 6
0
        /// <summary>Attempts to authenticate a user using Oculus Rift user data.</summary>
        public static void AuthenticateWithOculusRiftUserData(string oculusUserNonce,
                                                              int oculusUserId,
                                                              string oculusUserAccessToken,
                                                              bool hasUserAcceptedTerms,
                                                              Action <UserProfile> onSuccess,
                                                              Action <WebRequestError> onError)
        {
            LocalUser.ExternalAuthentication = new ExternalAuthenticationData()
            {
                provider       = ExternalAuthenticationProvider.OculusRift,
                ticket         = oculusUserAccessToken,
                additionalData = new Dictionary <string, string>()
                {
                    { ExternalAuthenticationData.OculusRiftKeys.NONCE, oculusUserNonce },
                    { ExternalAuthenticationData.OculusRiftKeys.USER_ID, oculusUserId.ToString() },
                },
            };

            APIClient.RequestOculusRiftAuthentication(oculusUserNonce, oculusUserId, oculusUserAccessToken, hasUserAcceptedTerms,
                                                      (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                UserAccountManagement.UpdateUserProfile(onSuccess, onError);
            },
                                                      onError);
        }
Ejemplo n.º 7
0
 public static void AuthenticateWithSteamEncryptedAppTicket(byte[] authTicketData,
                                                            Action <UserProfile> onSuccess,
                                                            Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithSteamEncryptedAppTicket(authTicketData,
                                                                   false,
                                                                   onSuccess, onError);
 }
Ejemplo n.º 8
0
        /// <summary>Attempts to authenticate a user using a Steam Encrypted App Ticket.</summary>
        /// <remarks>This version is designed to match the FacePunch.SteamWorks implementation by
        /// @garrynewman at https://github.com/Facepunch/Facepunch.Steamworks</remarks>
        public static void AuthenticateWithSteamEncryptedAppTicket(byte[] authTicketData,
                                                                   Action <UserProfile> onSuccess,
                                                                   Action <WebRequestError> onError)
        {
            string encodedTicket = Utility.EncodeEncryptedAppTicket(authTicketData, (uint)authTicketData.Length);

            UserAccountManagement.AuthenticateWithSteamEncryptedAppTicket(encodedTicket, onSuccess, onError);
        }
Ejemplo n.º 9
0
        /// <summary>Attempts to authenticate a user using a GOG Encrypted App Ticket.</summary>
        public static void AuthenticateWithGOGEncryptedAppTicket(byte[] data, uint dataSize,
                                                                 Action <UserProfile> onSuccess,
                                                                 Action <WebRequestError> onError)
        {
            string encodedTicket = Utility.EncodeEncryptedAppTicket(data, dataSize);

            UserAccountManagement.AuthenticateWithGOGEncryptedAppTicket(encodedTicket, onSuccess, onError);
        }
Ejemplo n.º 10
0
        /// <summary>Attempts to authenticate a user using a Steam Encrypted App Ticket.</summary>
        /// <remarks>This version is designed to match the Steamworks.NET implementation by
        /// @rlabrecque at https://github.com/rlabrecque/Steamworks.NET</remarks>
        public static void AuthenticateWithSteamEncryptedAppTicket(byte[] pTicket, uint pcbTicket,
                                                                   Action <UserProfile> onSuccess,
                                                                   Action <WebRequestError> onError)
        {
            string encodedTicket = Utility.EncodeEncryptedAppTicket(pTicket, pcbTicket);

            UserAccountManagement.AuthenticateWithSteamEncryptedAppTicket(encodedTicket, onSuccess, onError);
        }
Ejemplo n.º 11
0
 public static void AuthenticateWithOculusRiftUserData(string oculusUserNonce,
                                                       int oculusUserId,
                                                       string oculusUserAccessToken,
                                                       Action <UserProfile> onSuccess,
                                                       Action <WebRequestError> onError)
 {
     UserAccountManagement.AuthenticateWithOculusRiftUserData(oculusUserNonce, oculusUserId,
                                                              oculusUserAccessToken,
                                                              false,
                                                              onSuccess, onError);
 }
Ejemplo n.º 12
0
        /// <summary>Begins the authentication process using a mod.io Security Code.</summary>
        public static void AuthenticateWithSecurityCode(string securityCode,
                                                        Action <UserProfile> onSuccess,
                                                        Action <WebRequestError> onError)
        {
            APIClient.GetOAuthToken(securityCode, (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                UserAccountManagement.UpdateUserProfile(onSuccess, onError);
            },
                                    onError);
        }
Ejemplo n.º 13
0
        /// <summary>Attempts to authenticate a user using an emailed security code.</summary>
        public static void AuthenticateWithSecurityCode(string securityCode,
                                                        Action <UserProfile> onSuccess,
                                                        Action <WebRequestError> onError)
        {
            APIClient.GetOAuthToken(securityCode, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    steamTicket      = null,
                    gogTicket        = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                    onError);
        }
Ejemplo n.º 14
0
        /// <summary>Attempts to authenticate a user using a GOG Encrypted App Ticket.</summary>
        public static void AuthenticateWithGOGEncryptedAppTicket(string encodedTicket,
                                                                 Action <UserProfile> onSuccess,
                                                                 Action <WebRequestError> onError)
        {
            APIClient.RequestGOGAuthentication(encodedTicket, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    gogTicket        = encodedTicket,
                    steamTicket      = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                               onError);
        }
Ejemplo n.º 15
0
        /// <summary>Attempts to authenticate a user using Xbox Live credentials.</summary>
        public static void AuthenticateWithXboxLiveToken(string xboxLiveUserToken,
                                                         Action <UserProfile> onSuccess,
                                                         Action <WebRequestError> onError)
        {
            LocalUser.ExternalAuthentication = new ExternalAuthenticationData()
            {
                ticket   = xboxLiveUserToken,
                provider = ExternalAuthenticationProvider.XboxLive,
            };

            APIClient.RequestXboxLiveAuthentication(xboxLiveUserToken, (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                UserAccountManagement.UpdateUserProfile(onSuccess, onError);
            },
                                                    onError);
        }
Ejemplo n.º 16
0
        /// <summary>Attempts to authenticate a user using a GOG Encrypted App Ticket.</summary>
        public static void AuthenticateWithGOGEncryptedAppTicket(string encodedTicket,
                                                                 Action <UserProfile> onSuccess,
                                                                 Action <WebRequestError> onError)
        {
            LocalUser.ExternalAuthentication = new ExternalAuthenticationData()
            {
                ticket   = encodedTicket,
                provider = ExternalAuthenticationProvider.Steam,
            };

            APIClient.RequestGOGAuthentication(encodedTicket, (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                UserAccountManagement.UpdateUserProfile(onSuccess, onError);
            },
                                               onError);
        }
Ejemplo n.º 17
0
        /// <summary>Attempts to authenticate a user using an itch.io JWT Token.</summary>
        public static void AuthenticateWithItchIOToken(string jwtToken,
                                                       bool hasUserAcceptedTerms,
                                                       Action <UserProfile> onSuccess,
                                                       Action <WebRequestError> onError)
        {
            LocalUser.ExternalAuthentication = new ExternalAuthenticationData()
            {
                ticket   = jwtToken,
                provider = ExternalAuthenticationProvider.ItchIO,
            };

            APIClient.RequestItchIOAuthentication(jwtToken, hasUserAcceptedTerms,
                                                  (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                UserAccountManagement.UpdateUserProfile(onSuccess, onError);
            },
                                                  onError);
        }
Ejemplo n.º 18
0
 public static void ReauthenticateWithStoredExternalAuthData(Action <UserProfile> onSuccess,
                                                             Action <WebRequestError> onError)
 {
     UserAccountManagement.ReauthenticateWithStoredExternalAuthData(false,
                                                                    onSuccess, onError);
 }
Ejemplo n.º 19
0
        /// <summary>Attempts to reauthenticate using the stored external auth ticket.</summary>
        public static void ReauthenticateWithStoredExternalAuthData(bool hasUserAcceptedTerms,
                                                                    Action <UserProfile> onSuccess,
                                                                    Action <WebRequestError> onError)
        {
            ExternalAuthenticationData authData = LocalUser.ExternalAuthentication;

            Debug.Assert(!string.IsNullOrEmpty(authData.ticket));
            Debug.Assert(authData.provider != ExternalAuthenticationProvider.None);

            Action <string> onSuccessWrapper = (t) =>
            {
                LocalUser.OAuthToken       = t;
                LocalUser.WasTokenRejected = false;
                LocalUser.Save();

                if (onSuccess != null)
                {
                    UserAccountManagement.UpdateUserProfile(onSuccess, onError);
                }
            };

            switch (LocalUser.ExternalAuthentication.provider)
            {
            case ExternalAuthenticationProvider.Steam:
            {
                APIClient.RequestSteamAuthentication(authData.ticket,
                                                     hasUserAcceptedTerms,
                                                     onSuccessWrapper,
                                                     onError);
            }
            break;

            case ExternalAuthenticationProvider.GOG:
            {
                APIClient.RequestGOGAuthentication(authData.ticket,
                                                   hasUserAcceptedTerms,
                                                   onSuccessWrapper,
                                                   onError);
            }
            break;

            case ExternalAuthenticationProvider.ItchIO:
            {
                APIClient.RequestItchIOAuthentication(authData.ticket,
                                                      hasUserAcceptedTerms,
                                                      onSuccessWrapper,
                                                      onError);
            }
            break;

            case ExternalAuthenticationProvider.OculusRift:
            {
                string token        = authData.ticket;
                string nonce        = null;
                string userIdString = null;
                int    userId       = -1;
                string errorMessage = null;

                if (authData.additionalData == null)
                {
                    errorMessage = "The user id and nonce are missing.";
                }
                else if (!authData.additionalData.TryGetValue(ExternalAuthenticationData.OculusRiftKeys.NONCE, out nonce) ||
                         string.IsNullOrEmpty(nonce))
                {
                    errorMessage = "The nonce is missing.";
                }
                else if (!authData.additionalData.TryGetValue(ExternalAuthenticationData.OculusRiftKeys.USER_ID, out userIdString) ||
                         string.IsNullOrEmpty(userIdString))
                {
                    errorMessage = "The user id is missing.";
                }
                else if (!int.TryParse(userIdString, out userId))
                {
                    errorMessage = "The user id is not parseable as an integer.";
                }

                if (errorMessage != null)
                {
                    Debug.LogWarning("[mod.io] Unable to authenticate using stored Oculus Rift user data.\n"
                                     + errorMessage);

                    if (onError != null)
                    {
                        var error = WebRequestError.GenerateLocal(errorMessage);
                        onError(error);
                    }

                    return;
                }
                else
                {
                    APIClient.RequestOculusRiftAuthentication(nonce, userId, token,
                                                              hasUserAcceptedTerms,
                                                              onSuccessWrapper,
                                                              onError);
                }
            }
            break;

            case ExternalAuthenticationProvider.XboxLive:
            {
                APIClient.RequestXboxLiveAuthentication(authData.ticket,
                                                        hasUserAcceptedTerms,
                                                        onSuccessWrapper,
                                                        onError);
            }
            break;

            default:
            {
                throw new System.NotImplementedException();
            }
            }
        }