4

I am creating an Angular 4 application that redirects to Azure Active Directory for Authentication, however I am having an issue obtaining the returned token from Microsoft.

I have a route setup as follows

export const ROUTES:Routes = [
  { 
    path: '', redirectTo: 'login', pathMatch: 'full'
  },
  {
    path: 'access_token', component: LoginCallbackComponent
  }

Navigating to http://localhost:4200 takes me to the login page

When I click the Login button I am redirected to Microsoft and Authentication takes place via Azure AD. After successful Authentication, Microsoft routes me back to the the application with the following

http://localhost:4200/#access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSU.....etc...etc...

The 'access_token' route correctly calls the LoginCallbackComponent, however I cant seem to get at the 'access_token' value in the LoginCallbackComponent

The ActivatedRoute.snapshot does not show ny parameters, which I would imagine is my issue, but I am out of things to try

Can anyone push me in the right direction?

Thanks

-bc

bhantol
  • 9,368
  • 7
  • 44
  • 81
  • There is a similar question [here](https://stackoverflow.com/questions/38255939/how-to-handle-hash-fragments-from-oauth-redirect-urls-in-angular2-rc3-routing/). See if this helps you. – Aaron Chen Jul 21 '17 at 10:00
  • did you seolve this..same problem here :/ – Christo S. Christov Aug 23 '17 at 15:54
  • 1
    If using the hash, just use `location.hash` - if you want to use a query param, use the "?" like `http://localhost:4200/?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSU.....etc...etc...` – Guntram Mar 27 '18 at 09:29

0 Answers0