From c376bb1dac29d38d06609db2b8e91677f078d266 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Mon, 26 May 2014 15:20:26 +0200 Subject: [PATCH] JWTConfig should provide a cached transport constructor. --- jwt.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jwt.go b/jwt.go index 8568884..b225d19 100644 --- a/jwt.go +++ b/jwt.go @@ -76,6 +76,15 @@ func (c *JWTConfig) NewTransportWithUser(user string) Transport { return NewAuthorizedTransport(c, &Token{Subject: user}) } +func (c *JWTConfig) NewTransportWithCache(cache Cache) (Transport, error) { + token, err := cache.Read() + if err != nil { + return nil, err + } + c.cache = cache + return NewAuthorizedTransport(c, token), nil +} + // fetchToken retrieves a new access token and updates the existing token // with the newly fetched credentials. func (c *JWTConfig) FetchToken(existing *Token) (token *Token, err error) {