Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <activity
- android:name=".ui.backup.BackupActivity"
- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
- android:theme="@style/LibraryTheme">
- <action android:name="com.x.y.HANDLE_AUTHORIZATION_RESPONSE"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </activity>
- <activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
- <intent-filter>
- <action android:name="android.intent.action.VIEW"/>
- <category android:name="android.intent.category.DEFAULT"/>
- <category android:name="android.intent.category.BROWSABLE"/>
- <data android:scheme="com.x.y"/>
- </intent-filter>
- </activity>
- private void setupAuthorization() {
- AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
- Uri.parse("https://accounts.google.com/o/oauth2/v2/auth") /* auth endpoint */,
- Uri.parse("https://accounts.google.com/o/oauth2/token") /* token endpoint */
- );
- String clientId = "xxx.apps.googleusercontent.com";
- Uri redirectUri = Uri.parse("com.x.y:/oauth2callback");
- AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
- serviceConfiguration,
- clientId,
- AuthorizationRequest.RESPONSE_TYPE_CODE,
- redirectUri
- );
- builder.setScopes("https://www.googleapis.com/auth/drive");
- AuthorizationRequest request = builder.build();
- AuthorizationService authorizationService = new AuthorizationService(this);
- String action = "com.x.y.HANDLE_AUTHORIZATION_RESPONSE";
- Intent postAuthorizationIntent = new Intent(action);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, request.hashCode(), postAuthorizationIntent, 0);
- authorizationService.performAuthorizationRequest(request, pendingIntent);
- }
Add Comment
Please, Sign In to add comment