Updating authentication functions to prevent sending expired token.
Merge pull request #3266 from amhuber/master

Updating authentication functions to prevent sending expired token.