Skip to content

Commit

Permalink
Remove custom scheme placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
athilahs committed Sep 27, 2024
1 parent 8a89ff8 commit 6cc41f6
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 50 deletions.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ this redirect URI.

We recommend using a custom scheme based redirect URI (i.e. those of form
`my.scheme:/path`), as this is the most widely supported across all versions of
Android. To avoid conflicts with other apps, it is recommended to configure a
Android. To avoid conflicts with other apps, it is recommended to configure a
distinct scheme using "reverse domain name notation". This can either match
your service web domain (in reverse) e.g. `com.example.service` or your package
name `com.example.app` or be something completely new as long as it's distinct
Expand All @@ -290,15 +290,6 @@ possible if it contains illegal characters for URI schemes (like underscores)
or if you already have another handler for that scheme - so just use something
else.

When a custom scheme is used, AppAuth can be easily configured to capture
all redirects using this custom scheme through a manifest placeholder:

```groovy
android.defaultConfig.manifestPlaceholders = [
'appAuthRedirectScheme': 'com.example.app'
]
```

Alternatively, the redirect URI can be directly configured by adding an
intent-filter for AppAuth's RedirectUriReceiverActivity to your
AndroidManifest.xml:
Expand Down
3 changes: 0 additions & 3 deletions app/README-Google.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@
}
```

3. Finally, replace the `appAuthRedirectScheme` manifest placeholder in `build.gradle` (for Module: app) with
`com.googleusercontent.apps.PREFIX`.

After this is done, install the app (`./gradlew :app:installDebug`). Authorizing a Google account
and retrieving user info should now work.
16 changes: 5 additions & 11 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ with an invalid configuration.
The configuration file MUST contain a JSON object. The following properties can be specified:

- `redirect_uri` (required): The redirect URI to use for receiving the authorization response.
This can either be a custom scheme URI (com.example.app:/oauth2redirect/example-provider) or
an https app link (https://www.example.com/path). Custom scheme URIs are better supported
across all versions of Android, however many authorization server implementations require an
This can either be a custom scheme URI (com.example.app:/oauth2redirect/example-provider) or
an https app link (https://www.example.com/path). Custom scheme URIs are better supported
across all versions of Android, however many authorization server implementations require an
https URI. Consult the documentation for your authorization server.

The value specified here should match the value specified for `appAuthRedirectScheme` in the
`build.gradle` (Module: app), so that the demo app can capture the response.

- `end_session_redirect_uri` (required): The redirect URI to use for receiving the end session response.
This should be a custom scheme URI (com.example.app:/oauth2redirect/example-provider).
Consult the documentation for your authorization server.
This should be a custom scheme URI (com.example.app:/oauth2redirect/example-provider).
Consult the documentation for your authorization server.

The value specified here should match the value specified for `appAuthRedirectScheme` in the
`build.gradle` (Module: app), so that the demo app can capture the response.

NOTE: Scheme of the URI should be the same as `redirect_uri` but callback should be different.

- `authorization_scope` (required): The scope string to use for the authorization request.
Expand Down
6 changes: 0 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ android {
applicationId 'net.openid.appauthdemo'
project.archivesBaseName = 'appauth-demoapp'
vectorDrawables.useSupportLibrary = true

// Make sure this is consistent with the redirect URI used in res/raw/auth_config.json,
// or specify additional redirect URIs in AndroidManifest.xml
manifestPlaceholders = [
'appAuthRedirectScheme': 'net.openid.appauthdemo'
]
}

signingConfigs {
Expand Down
5 changes: 1 addition & 4 deletions app/java/net/openid/appauthdemo/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ private void readConfiguration() throws InvalidConfigurationException {

if (!isRedirectUriRegistered()) {
throw new InvalidConfigurationException(
"redirect_uri is not handled by any activity in this app! "
+ "Ensure that the appAuthRedirectScheme in your build.gradle file "
+ "is correctly configured, or that an appropriate intent filter "
+ "exists in your app manifest.");
"redirect_uri is not handled by any activity in this app!");
}

if (getConfigString("discovery_uri") == null) {
Expand Down
9 changes: 1 addition & 8 deletions library/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@
android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar"
android:launchMode="singleTask" />

<activity android:name=".RedirectUriReceiverActivity" android:exported="true">
<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="${appAuthRedirectScheme}"/>
</intent-filter>
</activity>
<activity android:name=".RedirectUriReceiverActivity" android:exported="true"/>
</application>

<queries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
* destroys the browser tab before returning the result to the completion
* {@link android.app.PendingIntent}
* provided to {@link AuthorizationService#performAuthorizationRequest}.
*
* App developers using this library must override the `appAuthRedirectScheme`
* property in their `build.gradle` to specify the custom scheme that will be used for
* the OAuth2 redirect. If custom scheme redirect cannot be used with the identity provider
* you are integrating with, then a custom intent filter should be defined in your
* application manifest instead. For example, to handle
* `https://www.example.com/oauth2redirect`:
*
* ```xml
* <intent-filter>
* <action android:name="android.intent.action.VIEW"/>
Expand Down

0 comments on commit 6cc41f6

Please sign in to comment.