firebasefirebase-realtime-databaseoauth-2.0firebase-authenticationifttt

How to authenticate a Firebase user to an IFTTT service?


I'm trying to build an IFTTT service and connect it to my Firebase backend.

I need to authenticate user as indicated in the IFTTT docs: https://platform.ifttt.com/docs/api_reference#service-authentication

IFTTT’s protocol supports OAuth2 authentication, including support for refresh tokens if so desired.

Your service API should use access tokens for authentication and as a source of identity. A single access token should correspond to a single user account or resource owner on your service.

If refresh tokens are used, they must be non-expiring. If refresh tokens are not used, access tokens must be non-expiring.

But I can only get short-lived access tokens from Firebase it seems. Where can I get or how can I generate such tokens from the Firebase auth SDK?


Update in response to @FrankvanPuffelen:

I'll create an IFTTT service running on a Node server (possibly simply Cloud Functions) that will use the Firebase RTDB to send formatted HTTP request back to IFTTT. IFTTT requires me to authorize user accounts. Their required UX is something like this:

Part of the question is: Can I use the Firebase Auth API to get those tokens, etc. or do I need to create a new OAuth 2.0 "layer" with my own generated tokens for IFTTT?

PS: I'm very new to OAuth, so it's all a bit confusing to me, sorry if the question isn't very clear.


Solution

  • I'm posting my solution here, this is a rough draft of what I did at at the time.


    I'm using this auth method: My API has users with non-expiring OAuth2 access tokens and have an Express server responding at a Firebase HTTPS Cloud Function endpoint. Currently, at the prototyping stage, it generates fake tokens from the UID that are successfully accepted by IFTTT.

    It's a redirect-heavy authentification flow based on this old IFTTT api example: https://github.com/IFTTT/connect_with_ifttt_auth_sample

    Here's the gist of it:

    Sample code here: https://gist.github.com/nathanvogel/15ed311258b91d7ec3d25f44047780e2