Docker/WSL2 + Azure AD – invalid_token

Joe Blogs

If you see the below error using Azure AD authentication within an Angular or API project when using Docker with WSL2, one of the reasons could be the time within your Linux Distro is incorrect:

Bearer error=”invalid_token”, error_description=”The token is not valid before …”

If using Ubuntu, open Ubuntu and type “date” in the command prompt. This should show you the current date/time the clock is set too. If like me your date is set to a time in the past, you can update the clock by typing:

sudo date –set=”insert your current datetime here {YYYY-MM-dd HH:mm:ss.sss}”

The next time you authenticate this error should not be present