adick@blm.gov_BLM_EGIS

OAuthLoginManager

Discussion created by adick@blm.gov_BLM_EGIS on May 10, 2019
Latest reply on May 17, 2019 by gheppner-esristaff

I am trying to update our application to 100.5 from 10.2.9.  I am trying to authenticate the application and have an application setup for the application in our AGOL Organization with a client id and redirect uri.  Am running into issues using OAuthLoginManager when I run oAuthLoginManager.launchOAuthBrowserPage(context); I get the message...

Please copy this code, switch to your application and paste it there.  Struggling to find a good example that describes this.  Also strange that it opens up Chrome rather than opening within the app as it did with 10.2.9.  Any guidance in the right direction greatly appreciated.  

 

 

 

 

private OAuthManagement() {

final int OAUTH_EXPIRATION_NEVER = -1;
oAuthLoginManager = new OAuthLoginManager("https://arcgis.com", "YOUR_CLIENT_ID", "urn:ietf:wg:oauth:2.0:oob", OAUTH_EXPIRATION_NEVER);
}

public void LaunchLogin(Context context) {
oAuthLoginManager.launchOAuthBrowserPage(context);
}

public void handleTokenCredential(Intent intent) {
portal = new Portal("https://www.arcgis.com", true);
ListenableFuture<OAuthTokenCredential> futureToken = oAuthLoginManager.fetchOAuthTokenCredentialAsync(intent);

try {
OAuthTokenCredential oAuthTokenCredential = futureToken.get();
portal.setCredential(oAuthTokenCredential);
portal.loadAsync();
portal.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
if(portal.getLoadStatus() == LoadStatus.LOADED) {
ArcGISRuntimeEnvironment.setLicense(portal.getPortalInfo().getLicenseInfo());
}
}
});

} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}

Outcomes