ARTICLE AD BOX
I am trying to use AppAuth-Android to authenticate with the Fitbit Web API.
I call AuthorizationService.performAuthorizationRequest() to show the Fitbit OAuth interface:
val authEndpoint = Uri.parse(config.FITBIT_AUTH_URL) val tokenEndpoint = Uri.parse(config.FITBIT_TOKEN_URL) val redirectUrl = Uri.parse(config.FITBIT_REDIRECT_URL) val authConfig = AuthorizationServiceConfiguration(authEndpoint, tokenEndpoint) val request = AuthorizationRequest.Builder(authConfig, config.FITBIT_CLIENT_ID, ResponseTypeValues.CODE, redirectUrl) .setPrompt("consent") .setScope(config.FITBIT_SCOPES.joinToString((" "))) .build() val completionIntent = PendingIntent.getActivity( this, 0, Intent(this, AuthorizeFitbitActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK }, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE ) val cancelIntent = PendingIntent.getActivity( this, 1, Intent(this, AuthorizeFitbitActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK putExtra(EXTRA_AUTH_CANCELLED, true) }, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE ) this.fitbitAuthService.performAuthorizationRequest(request, completionIntent, cancelIntent)The interface does show, but in a different task, so when the user finishes and dismisses the authorization web interface, they now have two instances of my app.
How can I either keep the web interface in my app's task, or close the task after they dismiss it so I'm back to a single instance?
