Thread-safe Google OAuth 2.0 authorization code flow that manages and persists end-user credentials.
This is designed to simplify the flow in which an end-user authorizes the application to access their protected data, and then the application has access to their data based on an access token and a refresh token to refresh that access token when it expires.
The first step is to call {@link #loadCredential(String)} based on the known user ID to check ifthe end-user's credentials are already known. If not, call {@link #newAuthorizationUrl()} anddirect the end-user's browser to an authorization page. The web browser will then redirect to the redirect URL with a {@code "code"} query parameter which can then be used to request an accesstoken using {@link #newTokenRequest(String)}. Finally, use {@link #createAndStoreCredential(TokenResponse,String)} to store and obtain a credential foraccessing protected resources.
The default for the {@code approval_prompt} and {@code access_type} parameters is {@code null}. For web applications that means {@code "approval_prompt=auto&access_type=online"} and forinstalled applications that means {@code "approval_prompt=force&access_type=offline"}. To override the default, you need to explicitly call {@link Builder#setApprovalPrompt(String)} and{@link Builder#setAccessType(String)}.
@since 1.7
@author Yaniv Inbar