public class GoogleClient extends Object
The sample shows how to obtain a valid token for using Google APIs.
Prerequisites.
You will need a valid OAuth 2.0 client registered in Google API console at
https://console.developers.google.com.
More specifically, you will need
'client id', 'client secret', 'redirect uri' exactly as specified in the
console section 'Credentials' (download as json if you are missing the
redirect url).
Additionally, you will need also API scopes for the
APIs enabled in the console that you intend to use with the token you will be
requesting.
Using the sample.
To trigger a token request the sample needs a couple of parameters from your
client and apis that you will use with the token (specified above).
You
can supply them as environment variables and run the java program or you can
supply them interactively in the command line. Mixing the two options is also
possible, i.e. supply part of the parameters as environment variables and
another part interactively.
The names of the environment variables
that you can use to supply the parameters are:
Reference
https://developers.google.com/identity/protocols/OAuth2WebServer
| Constructor and Description |
|---|
GoogleClient() |
public static void main(String[] args) throws OAuth2ProtocolException, IOException
OAuth2ProtocolExceptionIOExceptionCopyright © 2017. All rights reserved.