Skip to content

Custom claims NoSuchMethodError #112

Description

@Mistic92

[REQUIRED] Step 2: Describe your environment

  • Library version: 5.6.0
  • Firebase Product: auth

[REQUIRED] Step 3: Describe the problem

I just upgraded to 5.6.0 version to try custom claims and now I can't get user because I get NoSuchMethodError

Exception in thread "firebase-default-0" java.lang.NoSuchMethodError: org.json.JSONObject.toMap()Ljava/util/Map;
	at com.google.firebase.auth.UserRecord.<init>(UserRecord.java:85)
	at com.google.firebase.auth.FirebaseUserManager.getUserById(FirebaseUserManager.java:112)
	at com.google.firebase.auth.FirebaseAuth$3.call(FirebaseAuth.java:266)
	at com.google.firebase.auth.FirebaseAuth$3.call(FirebaseAuth.java:263)
	at com.google.firebase.tasks.Tasks$1.run(Tasks.java:82)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Steps to reproduce:

So what I did.
I wanted to keep previous claims so I created copy of map and add new key-val.

    @Override
    public void addUserCustomClaims(final String userId, String key, String val) {
        final UserRecord user = getUser(userId);
        final Map<String, Object> customClaims = new HashMap<>(user.getCustomClaims());
        customClaims.put(key, val);
        final Void aVoid = Single.fromFuture(
            firebaseAuth.setCustomUserClaimsAsync(userId, customClaims))
            .blockingGet();
    }

It was inserted as I see but now I can't get user because it's throwing exception.
With breakpoint set to

Map<String, Object> parsed = new JSONObject(customClaims).toMap();

I see values

customClaims={"u_type":"USER"}
this.customClaims=null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions