Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom claims NoSuchMethodError #112

Closed
Mistic92 opened this issue Dec 9, 2017 · 4 comments
Closed

Custom claims NoSuchMethodError #112

Mistic92 opened this issue Dec 9, 2017 · 4 comments

Comments

@Mistic92
Copy link

Mistic92 commented Dec 9, 2017

[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
@google-oss-bot
Copy link

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

@hiranya911
Copy link
Contributor

Your app is using an incompatible version of the org.json:json dependency. You will have to inspect your dependency tree and ensure that there are no conflicting or incompatible artifacts. Here's what Firebase uses: https://github.com/firebase/firebase-admin-java/blob/master/pom.xml#L423

@jfzr
Copy link

jfzr commented Jun 18, 2018

This problem is still happening. Problem with Spring Test boot which have the vaadin dependency causing the problem

@Mistic92
Copy link
Author

@jfzr try to add this

configurations {
    compile.exclude module: "android-json"
    compile.exclude module: "com.vaadin.external.google"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants