Created
January 15, 2016 16:59
-
-
Save iperdomo/4073582d79037ba3e4a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/src/main/java/com/lnikkila/oidcsample/APIUtility.java b/app/src/main/java/com/lnikkila/oidcsample/APIUtility.java | |
index 37b33eb..49ebcf8 100644 | |
--- a/app/src/main/java/com/lnikkila/oidcsample/APIUtility.java | |
+++ b/app/src/main/java/com/lnikkila/oidcsample/APIUtility.java | |
@@ -58,7 +58,7 @@ public class APIUtility { | |
// launch it automatically here if you wanted to by grabbing the intent from the bundle. | |
try { | |
AccountManagerFuture<Bundle> futureManager = accountManager.getAuthToken(account, | |
- Authenticator.TOKEN_TYPE_ID, null, true, null, null); | |
+ Authenticator.TOKEN_TYPE_ACCESS, null, true, null, null); | |
idToken = futureManager.getResult().getString(AccountManager.KEY_AUTHTOKEN); | |
} catch (Exception e) { | |
diff --git a/app/src/main/java/com/lnikkila/oidcsample/oidc/authenticator/AuthenticatorActivity.java b/app/src/main/java/com/lnikkila/oidcsample/oidc/authenticator/AuthenticatorActivity.java | |
index 9934917..1be5031 100644 | |
--- a/app/src/main/java/com/lnikkila/oidcsample/oidc/authenticator/AuthenticatorActivity.java | |
+++ b/app/src/main/java/com/lnikkila/oidcsample/oidc/authenticator/AuthenticatorActivity.java | |
@@ -89,7 +89,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { | |
Set<String> parameterNames = url.getQueryParameterNames(); | |
// The URL will contain a `code` parameter when the user has been authenticated | |
- if (parameterNames.contains("code")) { | |
+ if (parameterNames.contains("code") && | |
+ Config.redirectUrl.equals(urlString.substring(0, urlString.indexOf("?")))) { | |
// We won't need to keep loading anymore. This also prevents errors when using | |
// redirect URLs that don't have real protocols (like app://) that are just | |
// used for identification purposes in native apps. | |
@@ -208,7 +209,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { | |
Map userInfo = Collections.emptyMap(); | |
try { | |
- userInfo = OIDCUtils.getUserInfo(Config.userInfoUrl, response.getIdToken()); | |
+ userInfo = OIDCUtils.getUserInfo(Config.userInfoUrl, response.getAccessToken()); | |
} catch (IOException e) { | |
Log.e(TAG, "Could not get UserInfo."); | |
e.printStackTrace(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment