Example #1
0
        public override GSTNResult <TokenResponseModel> RequestToken(string otp)
        {
            PwdTokenRequestModel model = new PwdTokenRequestModel {
            };
            var output = this.Post <PwdTokenRequestModel, TokenResponseModel>(model);

            token = output.Data;
            return(output);
        }
Example #2
0
        public virtual GSTNResult <TokenResponseModel> RequestToken(string otp)
        {
            PwdTokenRequestModel model = new PwdTokenRequestModel {
                action   = "ACCESSTOKEN",
                username = credential.username
            };

            model.app_key = EncryptionUtils.RsaEncrypt(this.GetAppKeyBytes(), credential.cert_file_rsa);
            byte[] dataToEncrypt = UTF8Encoding.UTF8.GetBytes(credential.password);
            model.password = EncryptionUtils.RsaEncrypt(dataToEncrypt, credential.cert_file_rsa);
            var output = this.Post <PwdTokenRequestModel, TokenResponseModel>(model);

            token             = output.Data;
            this.DecryptedKey = EncryptionUtils.AesDecrypt(token.sek, this.GetAppKeyBytes());

            return(output);
        }
Example #3
0
        public GSTNResult <TokenResponseModel> RequestToken(string otp)
        {
            dicParams.Clear();
            PwdTokenRequestModel model = new PwdTokenRequestModel();
            var output = this.Post <PwdTokenRequestModel, TokenResponseModel>(model);

            if (output.Data != null)
            {
                if (myUtils.cValTN(output.Data.expiry) == 0 && output.Data.auth_token_expires_at.HasValue)
                {
                    output.Data.expiry = (int)((output.Data.auth_token_expires_at.Value - DateTime.Now).TotalMinutes);
                }
                if (output.Data.expiry <= 0)
                {
                    output.Data.expiry = 360;
                }
            }
            return(output);
        }
Example #4
0
        public GSTNResult <TokenResponseModel> RequestToken(string otp)
        {
            dicParams.Clear();
            PwdTokenRequestModel model = new PwdTokenRequestModel()
            {
                app_key  = EncryptionUtils.RsaEncrypt(this.GetAppKeyBytes(), credential.cert_file_rsa),
                action   = "ACCESSTOKEN",
                username = this.username,
                password = EncryptionUtils.RsaEncrypt(UTF8Encoding.UTF8.GetBytes(this.password), credential.cert_file_rsa)
            };
            string finalJson = this.Serialize(model);

            this.LogMessage(finalJson);
            dicParams.Add("RequestPayload", finalJson);
            var output = this.Post <PwdTokenRequestModel, TokenResponseModel>(model);

            try
            {
                if (output.Data != null)
                {
                    output.Data.auth_token = output.Data.authtoken;
                    this.token             = output.Data;
                    this.DecryptedKey      = EncryptionUtils.AesDecrypt(token.sek, this.GetAppKeyBytes());
                    this.LogMessage(this.token.auth_token);

                    if (myUtils.cValTN(output.Data.expiry) == 0 && output.Data.auth_token_expires_at.HasValue)
                    {
                        output.Data.expiry = (int)((output.Data.auth_token_expires_at.Value - DateTime.Now).TotalMinutes);
                    }
                    if (output.Data.expiry <= 0)
                    {
                        output.Data.expiry = 360;
                    }
                }
            }
            catch (Exception ex)
            {
                output = this.BuildExceptionResult <TokenResponseModel>(ex);
            }
            return(output);
        }