"Sign in with Apple" - Realm Sync on iOS, manually authenticate on WatchOS

Hi,

I’m currently wondering how to work around the limitation that Realm Sync doesn’t support Apple Watch (feature request), and I figured I’d just manually connect to Atlas using GraphQL from the Watch instead. It wouldn’t support update notifications (AFAIK), but I could at least pull & push data from the Watch.

My question is about how best to authenticate with MongoDB as a user on the Watch, if the user normally “Signs In With Apple” on the phone.

Say for example that in the iOS app, the user would always use Sign In With Apple to login:

let credentials = Credentials.apple(idToken: "<token>")
app.login(credentials: credentials) { (result) in 
    .. 
}

You can also “Sign In With Apple” from the Watch, which would also give you a token to use.

Can that same token be used to manually authenticate via a different mechanism than the SDK, i.e. can I somehow use that same token to connect to Atlas via GraphQL?

Edit: I see it is possible to sign in using the Realm SDK from WatchOS, is there any way to extract an authentication token from there?

Thanks

Wait, this may be possible using the SDK. I found that you can still login from WatchOS, and then you can get an Access Token from the user session:

The user’s refresh token used to access the Realm Application.

This is required to make HTTP requests to MongoDB Realm’s REST API
for functionality not exposed natively. It should be treated as sensitive data.
@property (nullable, nonatomic, readonly) NSString *accessToken;

:tada: