Exemple #1
0
        /// <summary>
        /// Starts authentication by the user phone number and sends a confirmation code to their phone number
        /// </summary>
        /// <see cref="https://developers.xsolla.com/login-api/auth/oauth-20/oauth-20-start-auth-by-phone-number/"/>
        /// <param name="phoneNumber">User phone number.</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 SMS 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 OAuthStartAuthByPhoneNumber(string phoneNumber, string linkUrl, bool sendLink, Action <string> onSuccess, Action <Error> onError = null, string oauthState = null)
        {
            var data  = new StartAuthByPhoneNumberRequest(phoneNumber, linkUrl, sendLink);
            var state = oauthState ?? DEFAULT_OAUTH_STATE;
            var url   = string.Format(URL_OAUTH_START_AUTH_BY_PHONE_NUMBER, XsollaSettings.OAuthClientId, state);

            WebRequestHelper.Instance.PostRequest <StartAuthByPhoneNumberResponse, StartAuthByPhoneNumberRequest>(
                SdkType.Login,
                url,
                data,
                response => onSuccess?.Invoke(response.operation_id),
                onError,
                Error.LoginErrors);
        }
Exemple #2
0
        /// <summary>
        /// Starts authentication by the user phone number and sends a confirmation code to their phone number
        /// </summary>
        /// <see cref="https://developers.xsolla.com/login-api/auth/jwt/jwt-start-auth-by-phone-number/"/>
        /// <param name="phoneNumber">User phone number.</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 JwtStartAuthByPhoneNumber(string phoneNumber, string linkUrl, bool sendLink, Action <string> onSuccess, Action <Error> onError = null, string payload = null)
        {
            var data = new StartAuthByPhoneNumberRequest(phoneNumber, linkUrl, sendLink);
            var tokenInvalidationFlag = XsollaSettings.JwtTokenInvalidationEnabled ? "1" : "0";
            var url = string.Format(URL_JWT_START_AUTH_BY_PHONE_NUMBER, XsollaSettings.LoginId, XsollaSettings.CallbackUrl, tokenInvalidationFlag, payload);

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