# Angular organization login missing organization\_id in JWT

**URL:** <https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057>\
**Category:** Get Help\
**Tags:** organizations, jwt, angular, login\
**Created:** [October 10, 2022, 10:00am UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057 "2022-10-10T10:00:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![openbridge-james](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/openbridge-james/32/31303_2.png) [@openbridge-james](https://community.auth0.com/u/openbridge-james)\
**Post date:** [October 10, 2022, 10:00am UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057/1 "2022-10-10T10:00:49Z")

</div>

I have an Angular application that we have been using with auth0 for a while. We are working on integrating organization support into the code base.

In our app we have a component that is use to manage regular vs organizational login and invitations. when someone goes to a URL that is formatted like so.

`/login?organization=XXXXXXXXXXX`

It does direct me to the login for that organization. However, when the user is logged in their JWT token does not contain organization\_id segment, and therefore we don’t know they are login as a member of an organization.

Am I missing something here?

```auto
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AuthService } from '@auth0/auth0-angular';

@Component({
  selector: 'app-login',
  template: '',
  styleUrls: []
})
export class LoginComponent implements OnInit {

  constructor(
    private auth: AuthService,
    private activatedRoute: ActivatedRoute
  ) { }

  ngOnInit(): void {
    const queryParams = this.activatedRoute.snapshot.queryParams;
    const params = this.activatedRoute.snapshot.params;
    const queryParamsKeys = Object.keys(queryParams);
    const paramsKeys = Object.keys(params);

    if (queryParamsKeys.includes('invitation') && queryParamsKeys.includes('organization')) {
      this.organizationLoginWithInvitation(queryParams.organization, queryParams.invitation);
    }
    else if (queryParamsKeys.includes('organization')) {
      this.organizationLoginWithRedirect(queryParams.organization);
    }
    /*
    else if (paramsKeys.includes('organization')) {
      // Check for organization name with the API and if it exists get the organization ID from it.
      // and redirect to the correct login page.
      this.organizationLoginWithRedirect(params.organization);
    }
    else {
      this.auth.loginWithRedirect({
        redirect_uri: window.location.origin + '/auth/callback',
      });
    }
    */
  }

  private organizationLoginWithRedirect(organization: string): void {
    const payload = {
        organization: organization,
        redirect_uri: window.location.origin + '/auth/callback',
    };
    this.auth.loginWithRedirect(payload);
  }

  private organizationLoginWithInvitation(organization: string, invitation: string): void {
    this.auth.loginWithRedirect({
      organization: organization,
      invitation: invitation,
      redirect_uri: window.location.origin + '/auth/callback',
    });
  }

}

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 11, 2022, 11:26pm UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057/3 "2022-10-11T23:26:11Z")

</div>

Hey there @openbridge-james!

> [@openbridge-james](#):
>
> It does direct me to the login for that organization. However, when the user is logged in their JWT token does not contain organization\_id segment, and therefore we don’t know they are login as a member of an organization.

Very curious the `organization_id` isn’t present in the resulting tokens, it [should be](https://auth0.com/docs/manage-users/organizations/using-tokens#authenticate-users-through-an-organization). Can you confirm the `org_id` is indeed being included in the authorize call by inspecting the network requests?

Let us know!

---

<div class="post-metadata">

**Author:** ![openbridge-james](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/openbridge-james/32/31303_2.png) [@openbridge-james](https://community.auth0.com/u/openbridge-james)\
**Post date:** [October 17, 2022, 9:55am UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057/4 "2022-10-17T09:55:49Z")

</div>

I found the problem, it was not auth0 related, but the way we implemented some retry/redirect code that recalled loginonredirect without the organization.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 17, 2022, 6:12pm UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057/5 "2022-10-17T18:12:59Z")

</div>

Ah ok good to know you were able to get this sorted! Thanks for following up here 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 31, 2022, 6:13pm UTC](https://community.auth0.com/t/angular-organization-login-missing-organization-id-in-jwt/92057/6 "2022-10-31T18:13:09Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
