com.google.android.gms.search.SearchAuthApi |
API for Google Search auth.
Usage example:
SearchAuthApi searchAuthApi = SearchAuth.SearchAuthApi;
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(SearchAuth.API)
.build();
client.connect();
try {
// Invoke methods of searchAuthApi.
} finally {
client.disconnect();
}
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
SearchAuthApi.GoogleNowAuthResult |
Result of getGoogleNowAuth(GoogleApiClient, String) .
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Obtains authorization for the caller to use the Now API to publish to the Google Now user,
if any, on this device.
|
Obtains authorization for the caller to use the Now API to publish to the Google Now user, if any, on this device.
Usage example:
SearchAuthApi.GoogleNowAuthResult authResult;
try {
authResult = searchAuthApi.getGoogleNowAuth(client, WEB_APP_CLIENT_ID)
.await();
} finally {
client.disconnect();
}
Status status = authResult.getStatus();
if (status.isSuccess()) {
GoogleNowAuthState authState = authResult.getGoogleNowAuthState();
if (authState.getAuthCode() != null) {
// Send auth code to your server and from your server obtain OAuth refresh
// and access tokens.
} else if (authState.getAccessToken() != null) {
// Already obtained auth code before. To get a new auth code revoke this
// token and retry.
}
}
client | GoogleApiClient that includes API . |
---|---|
webAppClientId | Client ID, in the Google Developer Console, of the web application that will be using the Now API. |
SearchAuthApi.GoogleNowAuthResult
.