I am developing a Homey App for Strava (https://www.strava.com/) which I want to publish in the App store after finishing it.
I have created code that automatically adds a webhook and subscription so I can receive events that occur on Strava by following Strava Developers.
I have also added a driver and device to my App by using the homey-oauth2 module by following the steps on Home - Homey OAuth2.
Now when I add the first device, everything goes well;
- I can authorize the created Strava API Application with the required scopes by logging in on Strava with my personal Athlete account
- The device subsequently gets created and appears in my devices list
Next I want to create an additional device based on another Strava athlete account. For this other Strava account the same steps should be executed as described above.
The problem I am currently experiencing is;
- When I add a subsequent device Homey states that there are no devices available / I cannot add the new device
Any help would be very much appreciated.
The problem is that the homey-oauth2 module is configured by default to use the same session for all devices. So once you have logged in to connect your first device, the app remembers that user and reuses it when you add more devices.
The module has functions for checking and switching Configurations based on a configId, which stores the keys, etc. So I believe you need to find a way to prompt for a user as the first stage in the pairing wizard and then check to see if there is a Configuration for that user. If not then use the OAuth login to create one.
Sorry I can’t be more specific as I haven’t used it for multiple user accounts myself, but I don’t think it is easy.
I have tried it a couple of times having another configId other than default and multiple configs.
Where applying the default always seemed to work, other configid seem to lose sessions because the module cleans out sessions when something goes wrong, losing connection and auth.
So I ended up using default for the main implementation and a separate module without oauth2 from Homey for the others…