How to update current_user_metadata

Cannot find detailed explanation, how to update current user metadata. I’m developing SPA, want to do profile compltion through app custom form.

async updateMetadata(data: TUserMetadata) {
				const token = await getAccessTokenSilently({
					authorizationParams: {
						audience: `https://${state.config?.domain}/api/v2/`,
						scope: "update:current_user_metadata",
					},
				});
				const response = await fetch(`https://${state.config?.domain}/api/v2/users/${user.value?.sub}`, {
					method: "PATCH",
					headers: {
						'Authorization': 'Bearer ' + token,
						'Content-Type': 'application/json',
						'Accept': 'application/json'
					},
					body: JSON.stringify({ user_metadata: data })
				})
				return unwrapResponse(response, "json");
			},

Calling getAccessTokenSilently like this, system respond with error: “Consent required”
What I’m doing wrong? Maybe somthing else I should have done before requesting auth token?
Are these operations even possible in the free package?

Hi @anton.kalinichenko.d,

Welcome to the Auth0 Community!

Could you try including the offline_access scope in your request to see if it will skip any user interaction?

Thanks,
Rueben

token-request
Nothing changed

Hi @anton.kalinichenko.d,

Thanks for the update.

You might also need to go your API settings and toggle on the Allow Skipping User Consent option.

(Reference: How do I skip the consent page for my API Authorization flow? - #2 by amaanc)

Thanks,
Rueben

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