How to update user metadata from iOS SDK with native login?

First of all, there is a previous closed unaswered question here How to update user metadata from iOS SDK? My question is the same but i can add more details.

If I implement the native login using the SDK in this way:

        Auth0
              .authentication()
              .login(
                        usernameOrEmail: userNameOrEmail,
                        password: password,
            realm: "Username-Password-Authentication",
            scope: "openid profile offline_access read:current_user update:current_user_metadata")
        .start { result in

Then I can’t update the metadata with this:

                Auth0
                .users(token: accessToken)
                .patch(userInfo.sub,
                       userMetadata: metadata)
                .start { result in

So I decided to download and try the preconfigured sample app for my account and it works updating the metadata but only whith web login, the sample app performs this:

    Auth0
        .webAuth()
        .scope("openid profile offline_access read:current_user update:current_user_metadata")
        .audience("https://" + clientInfo.domain + "/api/v2/")
        .start {

and it gets a valid token for update the metadata in the way I tryed, but if I change the sample app code by hardcoding my login and using the SDK login it doesn’t get a valid access token for update the metadata.

This is very frustrating as I followed precisely the documentation. You can’t update users metadata if you login with the SDK it only works with webAuth login, you don’t specify this anywhere, you must add a table of available features under each available method or combination of methods or you have a bug that doesn’t look to be the case.

Anyway, great product, congrats.

1 Like

As you spotted the problem is that I’m not using the audience on the SDK login method as the web login does:

        Auth0
          .authentication()
          .login(
                    usernameOrEmail: userNameOrEmail,
                    password: password,
        realm: "Username-Password-Authentication",
       .audience("https://" + clientInfo.domain + "/api/v2/")
        scope: "openid profile offline_access read:current_user update:current_user_metadata")
    .start { result in

This solves the problem at all, with this I get a valid access token.

1 Like

Hey there @vgutierrez!

Thank you a lot for providing all that precise feedback regarding our iOS SDK docs. I’ll makae sure to relay it to appropriate team! Glad you were eventually able to figure it out!

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