Firebase FirebaseAuth.getInstance().createCustomToken(id); does not work anymore after update to new SDK

749 views
Skip to first unread message

Martín De Girolamo

unread,
Nov 8, 2016, 5:10:02 PM11/8/16
to Firebase Google Group
Hi There,

I'm having a new issue after firebase deprecate SDK authentication with service account. My project starting to give some error before running Gradle, I found that problem was my backend service on the project and read documentation on firebase and deprecated this, so library compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' is not working  anymore, I changed this for the new one compile 'com.google.firebase:firebase-admin:4.0.0' but  now I have a problem with createCustomToken method which is waitting for a TASK instead of String.... the line I have now is mToken = FirebaseAuth.getInstance().createCustomToken(id); but it's not working anymore.... somebody solve this issue???? I need to create a custom token and compile some changes on it before left to work. 
Firebase documentation as always still really bad and has no solution to it..... and I'm trying to get a solution as soon as possible.
Please Help.....
Regards,

   Martin,

Jacob Wenger

unread,
Nov 8, 2016, 5:24:29 PM11/8/16
to fireba...@googlegroups.com
Hey Martin,

How to create custom tokens using the new Admin Java SDK is documented here. The code sample you want is:

String uid = "some-uid";

FirebaseAuth.getInstance().createCustomToken(uid)
    .addOnSuccessListener(new OnSuccessListener<String>() {
        @Override
        public void onSuccess(String customToken) {
            // Send token back to client
        }
    });

Creating custom tokens changed from a synchronous to an asynchronous method, which is why the signature changed.

We are actively investigating what is going on with the compilation issues with firebase-server-sdk. We are still trying to track down what is amiss but hope to have it figured out shortly.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/65b36c30-39a9-4442-a300-3eeb78eafb89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacob Wenger

unread,
Nov 8, 2016, 6:40:27 PM11/8/16
to Jacob Wenger, fireba...@googlegroups.com
Just a quick follow-up. The firebase-server-sdk:3.0.2 build was busted, which is why your target is no longer compiling. We are pushing a new 3.0.3 build that fixes that issue, but in the meantime, you can change:

com.google.firebase:firebase-server-sdk:[3.0.0,)

to:

com.google.firebase:firebase-server-sdk:3.0.1

and that should resolve your issue. Otherwise, you can continue to use the 4.x.x builds (although we are about to push a new 4.0.1 build which fixes a separate database issue).

Cheers,
Jacob

Jacob Wenger

unread,
Nov 8, 2016, 8:30:17 PM11/8/16
to Jacob Wenger, fireba...@googlegroups.com
Okay, so the issues here should be resolved. We've published versions 3.0.3 of firebase-server-sdk and 4.0.1 of firebase-admin which should address all of the issues mentioned above. If you are using the firebase-admin package, you will need to use the code sample I provided above to create custom tokens. Please let us know if you run into any more issues.

Cheers,
Jacob
Message has been deleted

Martín De Girolamo

unread,
Nov 9, 2016, 9:54:21 AM11/9/16
to Firebase Google Group, ja...@firebase.com
Thank you very much Jacob.
Cheers,

   Martin,
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Ny Codes

unread,
Nov 15, 2016, 6:12:32 PM11/15/16
to Firebase Google Group, ja...@firebase.com
Is there a clear guidance around when to use firebase-server-sdk vs when to use firebase-admin or both?
I have gone through the docs for firebase-admin in auth and database section vs the firebase+GAE article which shows sending daily email and cannot decide/comprehend for the following tasks
  • send targeted push notifications from GAE based on some logic which resides on GAE (and not from console)
  • targeted push notifications are both of type  cron/batch as well as event driven  
    • e.g., cron/batch push notification for chat app to @JohnDoe- "You replied to 10 chats yesterday"
    • e.g., event-driven to @JaneDoe - "John Doe just invited you to a group chat, respond to see !"

Kindly suggest.

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Jacob Wenger

unread,
Nov 15, 2016, 6:34:18 PM11/15/16
to Ny Codes, Firebase Google Group, ja...@firebase.com
Hey Ny,

> Is there a clear guidance around when to use firebase-server-sdk vs when to use firebase-admin or both?

firebase-admin is just an updated version of firebase-server-sdk. They have different names, but their use cases are the same. Now that version 4.0.2 of the Firebase Admin Java SDK has been released and brings back Java 7 support, you should no longer need to use the firebase-server-sdk package.

> I have gone through the docs for firebase-admin in auth and database section vs the firebase+GAE article which shows sending daily email and cannot decide/comprehend for the following tasks

The Firebase Admin Java SDK does not have an API for sending push notifications, so I'm not sure exactly what you are referring to. Can you share a link to the article you are referring to?

Cheers,
Jacob
Reply all
Reply to author
Forward
0 new messages