Skip to content

Commit ff7235d

Browse files
committed
fix bug in when check if expaired or not
1 parent 29362fa commit ff7235d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Source/FikaAmazonAPI.Sample/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ static async Task Main(string[] args)
3232
{
3333

3434

35-
3635
AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
3736
{
3837
AccessKey = Environment.GetEnvironmentVariable("AccessKey"),
@@ -45,6 +44,15 @@ static async Task Main(string[] args)
4544
IsActiveLimitRate = true
4645
}) ;
4746

47+
//while (true)
48+
//{
49+
// var fromDate = DateTime.UtcNow.AddDays(-3);
50+
// var toDate = DateTime.UtcNow.AddDays(-1);
51+
// var ddddd = amazonConnection.Reports.CreateReportAndDownloadFile(ReportTypes.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA, fromDate, toDate);
52+
// Console.WriteLine(ddddd);
53+
//}
54+
55+
4856
DateTime startDate11 = new DateTime(2021, 10, 03);
4957
var data111 = amazonConnection.Reports.CreateReportAndDownloadFile(ReportTypes.GET_SELLER_FEEDBACK_DATA, startDate11, null, null);
5058

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/Token/CacheTokenData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CacheTokenData
1313

1414
public AWSAuthenticationTokenData GetAWSAuthenticationTokenData()
1515
{
16-
if (AWSAuthenticationTokenData != null && AWSAuthenticationTokenData.Expiration > DateTime.Now.Date.AddSeconds(-10))
16+
if (AWSAuthenticationTokenData != null && AWSAuthenticationTokenData.Expiration.AddSeconds(-60) > DateTime.Now)
1717
return AWSAuthenticationTokenData;
1818
else return null;
1919
}
@@ -78,7 +78,7 @@ public static bool IsTokenExpired(int? expiresIn, DateTime? dateCreated)
7878
if (dateCreated == null)
7979
return false;
8080
else
81-
return DateTime.UtcNow.Subtract((DateTime)dateCreated).TotalSeconds > expiresIn;
81+
return DateTime.UtcNow.Subtract((DateTime)dateCreated).TotalSeconds > (expiresIn-60); //Add Margent to a void expaired token
8282
}
8383
}
8484

Source/FikaAmazonAPI/Services/TokenGeneration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static IRestRequest SignWithSTSKeysAndSecurityToken(IRestRequest restRequ
4848
var req = new AssumeRoleRequest()
4949
{
5050
RoleArn = amazonCredential.RoleArn,
51-
DurationSeconds = 950, //put anything you want here
51+
DurationSeconds = 3600,
5252
RoleSessionName = Guid.NewGuid().ToString()
5353
};
5454

0 commit comments

Comments
 (0)