Java Code Examples for com.google.android.gms.auth.GoogleAuthUtil#clearToken()
The following examples show how to use
com.google.android.gms.auth.GoogleAuthUtil#clearToken() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DriveSyncService.java From narrate-android with Apache License 2.0 | 5 votes |
public DriveSyncService() throws UserRecoverableAuthException { super(SyncService.GoogleDrive); try { HttpTransport httpTransport = new NetHttpTransport(); JsonFactory jsonFactory = new JacksonFactory(); String token = GoogleAuthUtil.getToken(GlobalApplication.getAppContext(), Settings.getEmail(), "oauth2:" + DriveScopes.DRIVE_APPDATA); if (SettingsUtil.shouldRefreshGDriveToken()) { GoogleAuthUtil.clearToken(GlobalApplication.getAppContext(), token); token = GoogleAuthUtil.getToken(GlobalApplication.getAppContext(), Settings.getEmail(), "oauth2:" + DriveScopes.DRIVE_APPDATA); SettingsUtil.refreshGDriveToken(); } if (BuildConfig.DEBUG) LogUtil.log(getClass().getSimpleName(), "Access Token: " + token); GoogleCredential credential = new GoogleCredential().setAccessToken(token); service = new Drive.Builder(httpTransport, jsonFactory, credential).setApplicationName("Narrate").build(); } catch (UserRecoverableAuthException ue) { throw ue; } catch (Exception e) { LogUtil.log(getClass().getSimpleName(), "Exception in creation: " + e); if (!BuildConfig.DEBUG) Crashlytics.logException(e); } if (CLEAR_FOLDER_CONTENTS) { deleteEverything(); } }
Example 2
Source File: RNGoogleSigninModule.java From google-signin with MIT License | 5 votes |
@Override protected Void doInBackground(String... tokenToClear) { RNGoogleSigninModule moduleInstance = weakModuleRef.get(); if (moduleInstance == null) { return null; } try { GoogleAuthUtil.clearToken(moduleInstance.getReactApplicationContext(), tokenToClear[0]); moduleInstance.getPromiseWrapper().resolve(null); } catch (Exception e) { moduleInstance.promiseWrapper.reject(MODULE_NAME, e); } return null; }
Example 3
Source File: GoogleAuthHelper.java From ribot-app-android with Apache License 2.0 | 5 votes |
public String retrieveAuthToken(Account account) throws GoogleAuthException, IOException { String token = GoogleAuthUtil.getToken(mContext, account, SCOPE); // Token needs to be clear so we make sure next time we get a brand new one. Otherwise this // may return a token that has already been used by the API and because it's a one time // token it won't work. GoogleAuthUtil.clearToken(mContext, token); return token; }
Example 4
Source File: GoogleAccountCredential.java From google-api-java-client with Apache License 2.0 | 5 votes |
@Override public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException { try { if (response.getStatusCode() == 401 && !received401) { received401 = true; GoogleAuthUtil.clearToken(context, token); return true; } } catch (GoogleAuthException e) { throw new GoogleAuthIOException(e); } return false; }
Example 5
Source File: GoogleAccountsService.java From narrate-android with Apache License 2.0 | 4 votes |
public static boolean invalidateToken(String token) throws IOException, GoogleAuthException { GoogleAuthUtil.clearToken(GlobalApplication.getAppContext(), token); return true; }