In the previous recipe, we retrieved a token for our client and performed API requests. The downside of this approach is that we have no long-term storage for our token. In an HTTP server, for example, we'd like to have consistent storage of the token between requests.
This recipe will explore modifying the OAuth2 client to store a token between requests and retrieve it as required using a key. For the sake of simplicity, this key will be a file, but it could also be a database, Redis, and so on.
Getting ready
Refer to the Getting ready section in the Making use of OAuth2 clients recipe.
How to do it...
These steps cover writing and running of your application:
- From your Terminal or console application, create a new directory called ~/projects/go-programming-cookbook/chapter7/oauthstore, and navigate to this directory.
- Run the following command: