Skip to content

Commit 58c77ea

Browse files
authored
Add default value for TokenAudience and JwtExpiresAfter (#7)
1 parent b254d5e commit 58c77ea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Apple.AppStoreConnect/AppleAuthenticationPostConfigure.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
using Microsoft.Extensions.Options;
22
using Microsoft.IdentityModel.JsonWebTokens;
3+
using System;
34

45
namespace Apple.AppStoreConnect;
56

67
public sealed class AppleAuthenticationPostConfigure : IPostConfigureOptions<AppleAuthenticationOptions>
78
{
89
public void PostConfigure(string? name, AppleAuthenticationOptions options)
910
{
11+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
12+
if (options.TokenAudience is null)
13+
{
14+
options.TokenAudience = "appstoreconnect-v1";
15+
}
16+
1017
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
1118
if (options.SecurityTokenHandler is null)
1219
{
@@ -15,5 +22,11 @@ public void PostConfigure(string? name, AppleAuthenticationOptions options)
1522
SetDefaultTimesOnTokenCreation = false,
1623
};
1724
}
25+
26+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
27+
if (options.JwtExpiresAfter == TimeSpan.Zero)
28+
{
29+
options.JwtExpiresAfter = TimeSpan.FromMinutes(20);
30+
}
1831
}
1932
}

0 commit comments

Comments
 (0)