0

I'm trying to create a python app that pretends to be an android mobile app. The app I'm trying to mimic is using firebase cloud messaging client. and it's using the FirebaseMessaging.getInstance().getInstanceId() method to get a token.

Google documentation mentions:

On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token by extending FirebaseMessagingService and overriding onNewToken.

All the communications between the server is encrypted with this token. and in order to communicate the to app server I need to be able to generate this token.

My question is how can I generate a new token? is there a particular endpoint for this?

I've seen this and this but none of them mention how its getting done.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
Bamdad Dashtban
  • 354
  • 3
  • 17
  • Maybe you are looking for `onTokenRefresh` ? See this : https://stackoverflow.com/questions/38509563/firebase-token-is-generated-every-time-new There are also [another methods](https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId#inherited-method-summary) which can be helpful. – ʍѳђઽ૯ท Oct 20 '18 at 20:11
  • @Mohsen thanks but onTokenRefresh only notifies you when there is a change on token, my question is how to request for the token from the first place. I've tried to sniff the http traffic, but it doesn't look like there is any communication on http/https around this. – Bamdad Dashtban Oct 20 '18 at 20:15
  • 1
    But your question is : `how can I generate a new token` - Maybe using `deleteToken()` and then using `onTokenRefresh()` method ? – ʍѳђઽ૯ท Oct 20 '18 at 20:20
  • yes but I explain the constraints I have which is trying to do that with python not with Java on Android. You can't just ignore the context. – Bamdad Dashtban Oct 20 '18 at 20:59
  • There is no Python SDK to generate an FCM token, nor is there a public endpoint that you can call to generate such a token. The best I can think of is to generate an FCM token on a client (such as what Mohsen describes) and then send that to your server. – Frank van Puffelen Oct 20 '18 at 23:40
  • Thanks @FrankvanPuffelen i managed to get around this. – Bamdad Dashtban Oct 21 '18 at 20:55
  • Good to hear. It might be useful if you could share your solution in an answer, so that others can benefit from it if they have similar needs. – Frank van Puffelen Oct 21 '18 at 22:58

0 Answers0