I am stuck in very simple issue , not able to get the clue hence need your suggestions. So I am trying to authenticate lets say GoogleDrive APIs for that I use net.openid.appauth.AuthorizationRequest I create an Pending intent and pass this to authorization service to performAuthorizationRequest.Below is the sample code for the same :
AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
Uri.parse(AUTH_ENDPOINT_URL),
Uri.parse(TOKEN_ENDPOINT_URL)
);
Uri redirectUri = Uri.parse(getRedirectURI());
AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
serviceConfiguration,
“Xyzzy….”,
AuthorizationRequest.RESPONSE_TYPE_CODE,
redirectUri
);
builder.setScopes("https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.readonly");
AuthorizationRequest request = builder.build();
if (authorizationService != null) {
authorizationService.dispose();
}
authorizationService = new AuthorizationService(activity);
Intent postAuthorizationIntent = new Intent(“HANDLE_YOUTUBE_AUTHORIZATION_RESPONSE_ACTION”);
postAuthorizationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, request.hashCode(), postAuthorizationIntent, 0);
authorizationService.performAuthorizationRequest(request, pendingIntent);
Now this redirects to the Permission page of google drive and when I click on allow (permissions) I shall receive an intent back to the Activity which is added in pendingIntent . I can see that the RedirectUriReceiverActivity activity's onCreate is called and it sends the intent to the target
try {
target.send(this, 0, responseData);
} catch (CanceledException var10) {
Logger.errorWithStack(var10, "Unable to send pending intent", new Object[0]);
}
above try catch code from RedirectUriReceiverActivity onCreate() function
Code from Manifest file: RedirectUriReceiverActivity is added in Manifest file :
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
and have added view browse permission as well.
The issue which I am facing is I am not able to receive this intent. I override onNewIntent() in my activity where I expect this pendingIntent to return. But no help. Do I need to override any other function or am I missing something.
The AuthorizationService API is called from the Fragment that is created in the activity.
Can anyone suggest why the intent is not received in the Activity. Any help/guidance is highly appreciated.