Kirill_mitino
Kirill_mitino

Reputation: 55

How to prolong token expire date after each request(i use WebApi bearer token)

The problem:

Expire date for Ios,Android,WinPhone must be 1 year, but for Web - 5 minuts, and expire date must prolong after each user activity

Each request can contains PlatformType(or other info)

How prolong token expire date after each user activity?

Upvotes: 4

Views: 1261

Answers (1)

Dominique Alexandre
Dominique Alexandre

Reputation: 1053

You should use a Refresh Token when your main token has expired. This refresh token can have an expiration date of many days, your choice.

RefreshTokenProvider = new AuthenticationTokenProvider()
            {
                OnCreate = (obj) =>
                {
                    obj.Ticket.Properties.ExpiresUtc = DateTime.UtcNow.AddMonths(6);
                    obj.SetToken(obj.SerializeTicket());
                },
                OnReceive = (obj) => { obj.DeserializeTicket(obj.Token); }
            },

Upvotes: 1

Related Questions