# Get org\_id in Backend Call

**URL:** <https://community.auth0.com/t/get-org-id-in-backend-call/128841>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [March 4, 2024, 9:19am UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841 "2024-03-04T09:19:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klausbreyer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/klausbreyer/32/54591_2.png) [@klausbreyer](https://community.auth0.com/u/klausbreyer)\
**Post date:** [March 4, 2024, 9:19am UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841/1 "2024-03-04T09:19:37Z")

</div>

Hey there,

I have a SPA with a Go Backend. In the backend I need to know die user id and the org id. It is a pure b2b setting (no personal accounts alongside org accounts)

I am using [GitHub - auth0/go-jwt-middleware: A Middleware for Go Programming Language to check for JWTs on HTTP requests](https://github.com/auth0/go-jwt-middleware) to get the claims.  
Based on the claims I get the sub for the user id. So far so good. And because of the claims I know that this request is valid.

But how to get the org id? I know that the org id is in the JWT. But I am not sure, if I want to decode the JWT on my own. Is it secure when I do it after I the claims were verified through the middleware validator?

I have read quite some resources and I am on it for days, but maybe I am missing an important concept here?

---

<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:** [March 5, 2024, 1:14am UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841/3 "2024-03-05T01:14:28Z")

</div>

Hey @klausbreyer!

> [@klausbreyer](#):
>
> But how to get the org id? I know that the org id is in the JWT. But I am not sure, if I want to decode the JWT on my own. Is it secure when I do it after I the claims were verified through the middleware validator?

It’s common practice to decode/inspect claims from a protected backend - There’s actually a fairly straightforward example of this [here](https://github.com/auth0/go-jwt-middleware/blob/b4b1b5f6d1b1eb3c7f4538a29f2caf2889693619/examples/http-example/main.go#L22).

You will just want to update the `customClaimsExample` struct (and subsequent methods) to use `Org_id`:

```auto
type CustomClaimsExample struct {
	OrgId string `json:"org_id"`
	ShouldReject bool `json:"shouldReject,omitempty"`
}

```

---

<div class="post-metadata">

**Author:** ![klausbreyer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/klausbreyer/32/54591_2.png) [@klausbreyer](https://community.auth0.com/u/klausbreyer)\
**Post date:** [March 5, 2024, 8:30am UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841/4 "2024-03-05T08:30:05Z")

</div>

Thank you so much - this was the missing piece!

---

<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:** [March 5, 2024, 8:54pm UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841/5 "2024-03-05T20:54:45Z")

</div>

Awesome, happy to help!

---

<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:** [March 19, 2024, 8:55pm UTC](https://community.auth0.com/t/get-org-id-in-backend-call/128841/6 "2024-03-19T20:55:25Z")

</div>

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