How to get token from chrome local storage and store it in global variable?

Hi, i am trying to retrieve token value from chrome local storage but i am not sure if i am using the right code.
Could you please assist.

image
the value is adal.idtoken and i need to get the key/token from that value

This is the code that i am trying to use to get the value.

  1. String bearerToken = WebUI.executeJavaScript(“localStorage.getItem(‘adal.idtoken’)”, null)
    Script is executed but no value is retrieved (as i can see in debug mode)

  2. Then i am trying to store it in global variable:
    GlobalVariable.bearerToken = bearerToken

The correct syntax for retrieving adal token is:

def bearerToken = “”

bearerToken= WebUI.executeJavaScript(“return localStorage.getItem(‘adal.idtoken’)”, null)