Example #1
0
        /// <summary>
        /// Starts authentication by the user email address and sends a confirmation code to their email address.
        /// </summary>
        /// <see cref="https://developers.xsolla.com/login-api/auth/oauth-20/oauth-20-start-auth-by-email/"/>
        /// <param name="email">User email address.</param>
        /// <param name="linkUrl">URL to redirect the user to the status authentication page.</param>
        /// <param name="sendLink">Shows whether a link is sent with the confirmation code in the email or not.</param>
        /// <param name="oauthState">Value used for additional user verification on backend. Must be at least 8 symbols long. Will be "xsollatest" by default.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void OAuthStartAuthByEmail(string email, string linkUrl, bool sendLink, Action <string> onSuccess, Action <Error> onError = null, string oauthState = null)
        {
            var data  = new StartAuthByEmailRequest(email, linkUrl, sendLink);
            var state = oauthState ?? DEFAULT_OAUTH_STATE;
            var url   = string.Format(URL_OAUTH_START_AUTH_BY_EMAIL, XsollaSettings.OAuthClientId, state);

            WebRequestHelper.Instance.PostRequest <StartAuthByEmailResponse, StartAuthByEmailRequest>(
                SdkType.Login,
                url,
                data,
                response => onSuccess?.Invoke(response.operation_id),
                onError,
                Error.LoginErrors);
        }
Example #2
0
        /// <summary>
        /// Starts authentication by the user email address and sends a confirmation code to their email address.
        /// </summary>
        /// <see cref="https://developers.xsolla.com/login-api/auth/jwt/jwt-start-auth-by-email/"/>
        /// <param name="email">User email address.</param>
        /// <param name="linkUrl">URL to redirect the user to the status authentication page.</param>
        /// <param name="sendLink">Shows whether a link is sent with the confirmation code in the email or not.</param>
        /// <param name="payload">Custom data. The value of the parameter will be returned in the user JWT payload claim.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void JwtStartAuthByEmail(string email, string linkUrl, bool sendLink, Action <string> onSuccess, Action <Error> onError = null, string payload = null)
        {
            var data = new StartAuthByEmailRequest(email, linkUrl, sendLink);
            var tokenInvalidationFlag = XsollaSettings.JwtTokenInvalidationEnabled ? "1" : "0";
            var url = string.Format(URL_JWT_START_AUTH_BY_EMAIL, XsollaSettings.LoginId, XsollaSettings.CallbackUrl, tokenInvalidationFlag, payload);

            WebRequestHelper.Instance.PostRequest <StartAuthByEmailResponse, StartAuthByEmailRequest>(
                SdkType.Login,
                url,
                data,
                response => onSuccess?.Invoke(response.operation_id),
                onError,
                Error.LoginErrors);
        }