Skip to content

Commit c8f0073

Browse files
witrisnaiainmcgin
authored andcommitted
Provide response URI on completion (#133)
1 parent 5ffad67 commit c8f0073

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ public void onCreate(Bundle b) {
345345
}
346346
```
347347

348+
The full redirect URI is also provided in your completion intent:
349+
350+
```java
351+
public void onCreate(Bundle b) {
352+
// ...
353+
Uri redirectUri = getIntent().getData();
354+
// ...
355+
}
356+
```
357+
348358
Given the auth response, a token request can be created to exchange the
349359
authorization code:
350360

library/java/net/openid/appauth/AuthorizationManagementActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ private void handleAuthorizationComplete() {
243243
Logger.error("Failed to extract OAuth2 response from redirect");
244244
return;
245245
}
246+
responseData.setData(responseUri);
246247

247248
Logger.debug("Authorization complete - invoking completion intent");
248249
try {

library/javatests/net/openid/appauth/AuthorizationManagementActivityTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public void testSuccessFlow_withoutDestroy() {
128128
// after which the completion intent should be fired
129129
assertThat(mActivityShadow.getNextStartedActivity())
130130
.hasAction("COMPLETE")
131+
.hasData(mSuccessAuthRedirect)
131132
.hasExtra(AuthorizationResponse.EXTRA_RESPONSE);
132133
assertThat(mActivity).isFinishing();
133134
}
@@ -161,6 +162,7 @@ public void testSuccessFlow_withDestroy() {
161162
// after which the completion intent should be fired
162163
assertThat(mActivityShadow.getNextStartedActivity())
163164
.hasAction("COMPLETE")
165+
.hasData(mSuccessAuthRedirect)
164166
.hasExtra(AuthorizationResponse.EXTRA_RESPONSE);
165167
assertThat(mActivity).isFinishing();
166168
}
@@ -189,6 +191,7 @@ public void testFailureFlow_withoutDestroy() {
189191
// after which the completion intent should be fired
190192
assertThat(mActivityShadow.getNextStartedActivity())
191193
.hasAction("COMPLETE")
194+
.hasData(mErrorAuthRedirect)
192195
.hasExtra(AuthorizationException.EXTRA_EXCEPTION);
193196
assertThat(mActivity).isFinishing();
194197
}
@@ -210,6 +213,7 @@ public void testMismatchedState_responseDiffersFromRequest() {
210213
// the next activity should be from the completion intent, carrying an error
211214
assertThat(nextStartedActivity)
212215
.hasAction("COMPLETE")
216+
.hasData(authResponseUri)
213217
.hasExtra(AuthorizationException.EXTRA_EXCEPTION);
214218

215219
assertThat(AuthorizationException.fromIntent(nextStartedActivity))

0 commit comments

Comments
 (0)