# How to get user metadata with management API Go SDK

**URL:** <https://community.auth0.com/t/how-to-get-user-metadata-with-management-api-go-sdk/150054>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [October 17, 2024, 6:09pm UTC](https://community.auth0.com/t/how-to-get-user-metadata-with-management-api-go-sdk/150054 "2024-10-17T18:09:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Outbound5070](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Outbound5070](https://community.auth0.com/u/Outbound5070)\
**Post date:** [October 17, 2024, 6:09pm UTC](https://community.auth0.com/t/how-to-get-user-metadata-with-management-api-go-sdk/150054/1 "2024-10-17T18:09:41Z")

</div>

I need to get user metadata in a Go middleware function.

I followed the Go SDK quickstart and have the `profile` in the request context.

Here are the steps I’m taking. And where it’s going wrong.

Create a new management API instance:

```auto
auth0Api, err := management.New(
	auth0Domain,
	management.WithClientCredentials(ctx, auth0ClientId, auth0ClientSecret),
)

```

Get the userID in the middleware:

```auto
id := profile["sub"]

```

Everything works up to now. This is how I’m trying to get the user metadata with the management API.

```auto
user, err := auth0Api.User.Read(
	ctx,
	id, // The id returned from profile["sub"]
	management.IncludeFields("user_metadata", "app_metadata"),
)

```

This request fails to send. It appears to be sending a get request to `https://auth0domain/api/v2/users/userId` and a post request to `https://auth0domain/oauth/token` in the stack trace.

I got most of what I’ve done with the documentation at [GitHub - auth0/go-auth0: Go SDK for the Auth0 Management API.](https://github.com/auth0/go-auth0) and reading the definitions in the library.

But I’m struggling to find any examples on how to make this request.

What am I doing wrong?

What’s the correct way to get the user metadata?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [February 6, 2025, 11:57pm UTC](https://community.auth0.com/t/how-to-get-user-metadata-with-management-api-go-sdk/150054/2 "2025-02-06T23:57:06Z")

</div>

Hi @Outbound5070

I am sorry about the late reply to your post.

The requests that your applications sends seem to be correct ones. Make sure that you have authorized the client with the necessary scopes and that the clientID and secret are the right ones.

I can see that the Go-Auth0 SDK for the Management API does offer some numerous examples inside it for the different Management API calls.

Inside the **Management** folder, there us a **user\_test.go** file which you can explore for different test functions using the Management API. I have found this function which retrieves the user’s information:

```auto
func TestUserManager_Read(t *testing.T) {
	configureHTTPTestRecordings(t)

	expectedUser := givenAUser(t)

	actualUser, err := api.User.Read(context.Background(), expectedUser.GetID())

	assert.NoError(t, err)
	assert.Equal(t, expectedUser.GetID(), actualUser.GetID())
	assert.Equal(t, expectedUser.GetName(), actualUser.GetName())
}

```

Given this example, you should be able to use something like user.GetAppMetadata() or user.GetUserMetadata().

If you have any other questions or found a solution already, feel free to leave a reply or post on the community!

Kind Regards,  
Nik

---

<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:** [February 20, 2025, 11:57pm UTC](https://community.auth0.com/t/how-to-get-user-metadata-with-management-api-go-sdk/150054/4 "2025-02-20T23:57:26Z")

</div>

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