Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <activity
  2. android:name=".ui.backup.BackupActivity"
  3. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
  4. android:theme="@style/LibraryTheme">
  5. <action android:name="com.x.y.HANDLE_AUTHORIZATION_RESPONSE"/>
  6. <category android:name="android.intent.category.DEFAULT"/>
  7. </activity>
  8.  
  9. <activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
  10. <intent-filter>
  11. <action android:name="android.intent.action.VIEW"/>
  12.  
  13. <category android:name="android.intent.category.DEFAULT"/>
  14. <category android:name="android.intent.category.BROWSABLE"/>
  15.  
  16. <data android:scheme="com.x.y"/>
  17. </intent-filter>
  18. </activity>
  19.  
  20. private void setupAuthorization() {
  21. AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
  22. Uri.parse("https://accounts.google.com/o/oauth2/v2/auth") /* auth endpoint */,
  23. Uri.parse("https://accounts.google.com/o/oauth2/token") /* token endpoint */
  24. );
  25.  
  26. String clientId = "xxx.apps.googleusercontent.com";
  27. Uri redirectUri = Uri.parse("com.x.y:/oauth2callback");
  28. AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
  29. serviceConfiguration,
  30. clientId,
  31. AuthorizationRequest.RESPONSE_TYPE_CODE,
  32. redirectUri
  33. );
  34. builder.setScopes("https://www.googleapis.com/auth/drive");
  35. AuthorizationRequest request = builder.build();
  36. AuthorizationService authorizationService = new AuthorizationService(this);
  37.  
  38. String action = "com.x.y.HANDLE_AUTHORIZATION_RESPONSE";
  39. Intent postAuthorizationIntent = new Intent(action);
  40. PendingIntent pendingIntent = PendingIntent.getActivity(this, request.hashCode(), postAuthorizationIntent, 0);
  41. authorizationService.performAuthorizationRequest(request, pendingIntent);
  42. }
Add Comment
Please, Sign In to add comment