REST API Log in using access_token?

2 posts, 0 answers
  1. Bruce
    Bruce avatar
    6 posts
    Member since:
    Jan 2016

    Posted 06 Feb Link to this post

    All,

    I have the Login code working, and if successful, I store the access_token in local storage. I was wondering if there is a way using the REST API to log in a user using the stored access_token. I want to allow the user to go straight through to the app if their token hasn't expired, and take them to the login page if it has, and I don't want to store their credentials.

    Thanks,

    Brruce

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 09 Feb Link to this post

    Hi Bruce,

    To check whether the user is logged in use the /me endpoint before any business critical app request:

    You can reuse the access token you have locally when making the requests to the REST API. Just assign it to an Authorization header:
    Authorization: "bearer " + localStorage.getItem(accessTokenKeyName);

    I hope that this helps.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top