I am implementing a firebase realtime database on Wear OS for an accompanying app connected to an Android device and I was wondering what are the best practices for authenticating the user on a wear watch. It is not very convenient to enter a email and password on small watch screens. Is it possible to pass a firebase authorization token through the wear os data layer and if so, how would you use the token from the Android device to authenticate the user on the wear watch?
Thank you, Donny
The documentation covers the different authentication approaches you could use.
Ultimately, you will need at least a web-based method to authenticate the watch as you can't guarantee that the user will have your companion app installed or that the watch is not connected to an iOS device.
You have two approaches available to you (that I can think of):
Option 1: Short-lived token exchange
In this method, you perform the following steps:
RemoteIntentto open it for them)On the client side, you'd call the first function (after signing in) using either:
Then once the user has put in the code, send it off to
Option 2: PKCE
In this method, you perform the following steps:
sendAuthorizationRequest()flowhttps://wear.googleapis.com/3p_auth/com.your.package.namewith the GET parametersaccessTokenandrefreshToken.Note: This is probably overkill for what you are trying to do. But if you really don't want someone having to type in a code on their watch it is available as an option. You could use
oauth2-serverto just proxy issuing Firebase ID tokens (access tokens).