Assistance Requested: OAuth2 Authentication for Device Integration

Dear Homey Community Members,

I am currently developing a Homey app intended for device integration, which requires implementing OAuth2 authentication. The process, particularly around user login and token acquisition, has presented some challenges. My concerns primarily revolve around the user’s interaction with the OAuth2 flow, especially since the Homey app environment does not inherently support web browser capabilities.

The issue at hand is the acquisition of the authorization code needed for the OAuth2 token exchange. The Homey OAuth2 client documentation outlines a method onGetTokenByCode(Code), which necessitates an authorization code. The mechanism for obtaining this code within a non-web browser environment is unclear to me. Specifically, how can we enable a user to authenticate their account and grant access to the app, thus securing the authorization code?

I am seeking advice on the following points:
-Approaches for guiding users to an OAuth2 login page from within the Homey app.
-Methods for capturing the authorization code post-authentication.

I am reaching out for insights, shared experiences, or any resources that could assist in overcoming these hurdles.

Thank you in advance for your assistance and for sharing your knowledge.

Best regards,
Aayush

Check the manuals:

Install the npm package and follow the example… and with only defining the clientId/secet and auth URL you can get all to work without any coding :slight_smile: