Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

My Custom Web Api Login Module

I have created my own Login Module instead of using /token. As we can see that i am returning a refresh_token which allows my access_token to get a new one. -To access my login api i request http://localhost/api/Account/LoginUser and gets access_token, refresh_token and expiry dates.

Same as my Login Module i want to implement a RefreshToken where i can return a user new access_token with extended usage time.

What i have done so far is :

[Route("RefreshToken")]
    [AllowAnonymous]
    public  HttpResponseMessage GrantRefreshToken(OAuthGrantRefreshTokenContext context)
    {
        //enforce client binding of refresh token
        if (context.Ticket == null || context.Ticket.Identity == null || !context.Ticket.Identity.IsAuthenticated)
        {

            return new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent<object>(new
                {
                    Message = "Refresh token is not valid"
                }, Configuration.Formatters.JsonFormatter)
            };
        }
        else
        { // implement logic here}

But unable to get any context.

What i am doing wrong?? and please help me to implement it.

Thanks

share|improve this question
    
please don't add code in the form of an image. It's not searchable, which kind of defeats the whole purpose of this site... –  Wim Ombelets 22 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.