Skip to content

Commit

Permalink
Added code challenge method as a query param to UriAssembler
Browse files Browse the repository at this point in the history
  • Loading branch information
lalwani committed Jul 17, 2024
1 parent 168c1bd commit 6bea435
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<uses-permission android:name="android.permission.INTERNET" />

<application
<application android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ private void handleAuthCode(String authCode) {
).execute(new TokenRequestFlowCallback() {
@Override
public void onSuccess(AccessToken accessToken) {
Toast.makeText(
DemoActivity.this,
getString(R.string.token_success_message),
Toast.LENGTH_LONG
).show();
sharedPreferences.edit()
.putString(ACCESS_TOKEN, accessToken.getToken())
.apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public class AuthUriAssembler {
static final String PLATFORM_PARAM = "sdk";
static final String SDK_VERSION_PARAM = "sdk_version";
static final String CODE_CHALLENGE_PARAM = "code_challenge";

static final String CODE_CHALLENGE_METHOD = "code_challenge_method";

static final String CODE_CHALLENGE_METHOD_VAL = "S256";
public static Uri assemble(
@NonNull String clientId,
@NonNull String scopes,
Expand All @@ -57,7 +61,8 @@ public static Uri assemble(
.appendQueryParameter(REDIRECT_PARAM, redirectUri)
.appendQueryParameter(SDK_VERSION_PARAM, BuildConfig.VERSION_NAME)
.appendQueryParameter(SCOPE_PARAM, scopes)
.appendQueryParameter(CODE_CHALLENGE_PARAM, codeChallenge);
.appendQueryParameter(CODE_CHALLENGE_PARAM, codeChallenge)
.appendQueryParameter(CODE_CHALLENGE_METHOD, CODE_CHALLENGE_METHOD_VAL);
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<string name="custom_login_text">I want to sign in using my Uber app.</string>
<string name="app_link_sso">I want to sign in using App link</string>
<string name="authorization_code_message">Received an authorization code:\n %s</string>
<string name="token_success_message">Received auth token</string>
<string name="authorization_code_error_message">Could not get tokens via authorization code: %s</string>
<string name="greeting">Hello %s!</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user" />
<certificates src="system" />
</trust-anchors>
</debug-overrides>

<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>

0 comments on commit 6bea435

Please sign in to comment.