Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Get Current Auth Token #7413


User avatar
0
davidharrison created

Hi Guys,

When I'm logged into the applciation, I want to be able to get my current AuthToken. In the browser console, if I look at the abp.auth object, one if the properties is tokenCookieName which is set too "Abp.AuthToken", but the browser doesn't have a cookie called "Abp.AuthToken". There is also a function called getToken, but if I call this in the console, I only get a null result, presumably because there isn't a "Abp.AuthToken" cookie?

How do I get the current auth token client side? Does something additional need to be configured in the application?

Thanks,

David

project is .NET Core Zero 6.9 MVC & jQuery


4 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi @davidharrison,

    I just tried the abp.auth.getToken() method to see if it's null. It successfully returns the token. Be aware that only authenticated users can get the token. You can create a demo and test it on https://aspnetzero.com/demo

  • User Avatar
    0
    davidharrison created

    Hi @alper,

    Thank you for your responce. I am definately logged into the application when trying to revcieve the auth token, but the abp.auth.getToken() method still returns null, and the "Abp.AuthToken" cookie does not appear to be present in the browser.

    Do you know what might cause the cookie to not be set and available like this? Are there parts of the application where behaviour like this could inadvertently be configured?

    Thanks,

    David

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, did you use ANZ default login?

    or the login was done via a different authencation provider?

  • User Avatar
    0
    wilsonc created

    Hello, same problem with me. Any suggestion?

    The demonstration project in 'angular' version does not occur! 'abp.auth.getToken()' returns the token on console normally.

    My version is .NET Core Zero 9.1 MVC and jQuery