Reputation: 157
I'm integrating Azure AD login authentication to my web app. I have created an account in azure development portal and registered my app details. Following detail are provided during the app registration in azure portal. I have provided my web app's login URL for Sign-on URL
Sign-on URL -> https://my-sample-app/my.dashboard/
Redirect url is ->https://my-sample-app/my.dashboard/azureLogin.html?
Now when I login to portal.office.com and sign in with my credentials , I can see my web apps icon in the office 365 landing page. when I select my web app's icon , I'm getting redirected to my web app's login page instead of redirecting to the redirect URL provided during app registration.
Initially I didn't provide the Sign-on URL but once I tested without providing this I got "undefined Sign-on URL provided for app" error. So I provided my web app's login URL for Sign-on URL field, now I'm getting redirecting to my web app's login page instead of the mentioned redirect URL
I have used ADAL library for acquiring the access token . below is the code.
private AuthenticationResult acquireTokenByAuthorizationCode(String authCode) {
String authority = System.getProperty("dashboard.azure.authority.url", "https://login.microsoftonline.com/xxxxxxxxxxxxxxxxxxx/oauth2/token");
String clientId = System.getProperty("dashboard.azure.client.id", "xxxxxxxxxxxxxxxxxxxxxxxxx");
String clientSecret = System.getProperty("dashboard.azure.client.secret", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
String redirectUrl = System.getProperty("dashboard.azure.redirect.uri", "https://my-sample-app/my.dashboard/azureLogin.html?");
AuthenticationResult result = null;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext(authority, false, service);
ClientCredential credential = new ClientCredential(clientId, clientSecret);
Future<AuthenticationResult> future = context.acquireTokenByAuthorizationCode(authCode, URI.create(redirectUrl), credential, null);
result = future.get();
} catch (Exception e) {
LOGGER.error("Error occurred while acquiring token from Azure {}", e.getMessage());
throw new Exception(String.format("Error occurred while acquiring token from Azure. %s", e.getMessage()));
}
return result;
}
I'm sure that issue is not with the code. please advise what I'm missing here
Upvotes: 1
Views: 1936