Created
June 24, 2016 18:11
-
-
Save tushargupta51/78ce0b6bce998f6851abd02d91eb3a95 to your computer and use it in GitHub Desktop.
App reloading inside iFrame when renewing token - Solution 1
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
'use strict'; | |
if (window !== window.parent) { | |
angular.module('todoApp', ['AdalAngular']) | |
.config(['$httpProvider', 'adalAuthenticationServiceProvider', function ($httpProvider, adalProvider) { | |
adalProvider.init( | |
{ | |
clientId: 'Enter your client ID here e.g. e9a5a8b6-8af7-4719-9821-0deef255f68e', | |
}, | |
$httpProvider | |
); | |
}]); | |
} | |
else { | |
angular.module('todoApp', ['ngRoute','AdalAngular']) | |
.config(['$routeProvider', '$httpProvider', 'adalAuthenticationServiceProvider', function ($routeProvider, $httpProvider, adalProvider) { | |
$routeProvider.when("/Home", { | |
controller: "homeCtrl", | |
templateUrl: "/App/Views/Home.html", | |
}).when("/TodoList", { | |
controller: "todoListCtrl", | |
templateUrl: "/App/Views/TodoList.html", | |
requireADLogin: true, | |
}).when("/UserData", { | |
controller: "userDataCtrl", | |
templateUrl: "/App/Views/UserData.html", | |
}).otherwise({ redirectTo: "/Home" }); | |
adalProvider.init( | |
{ | |
instance: 'https://login.microsoftonline.com/', | |
tenant: 'Enter your tenant name here e.g. contoso.onmicrosoft.com', | |
clientId: 'Enter your client ID here e.g. e9a5a8b6-8af7-4719-9821-0deef255f68e', | |
extraQueryParameter: 'nux=1', | |
//cacheLocation: 'localStorage', // enable this for IE, as sessionStorage does not work for localhost. | |
}, | |
$httpProvider | |
); | |
}]); | |
} |
For me it looks like loop, you go to frameRedirect.html and it redirects you to the same page
@tushargupta51, can you please update the https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp sample with one of your solutions. That will save a lot of people, first by preventing them from running into this issue and thus by avoid searching for solutions on the web.
How will this work if my SPA is actually loaded within an iframe of another application?
@nandun5, Have you resolved this issue? I am facing the same challenge that our application is loaded in another iframe and I am getting CORS error while getting access token.
For me this goes into infinite looping reloading
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tushargupta51 how auth context will know the url to navigate to in iframe? As I know it is taken from AD according your client id and actually it equals to what you register through Azure AD Portal. There is no extra setting for it so far.