CloudOAuth2Callback

A OAuth2 Callback class that can be used to log-in using OAuth2

Example

let myOAuth2Callback = await this.homey.cloud.createOAuth2Callback(apiUrl);

myOAuth2Callback
  .on('url', url => {
    // the URL which should open in a popup for the user to login
  })
  .on('code', code => {
    // ... swap your code here for an access token
  });

Events

code

.on('code')

This event is fired when a OAuth2 code has been received. The code can usually be swapped by the app for an access token.

Parameters

Name Type Description
code
string | Error

The OAuth2 code, or an Error when something went wrong

url

.on('url')

This event is fired when a URL has been received. The user must be redirected to this URL to complete the sign-in process.

Parameters

Name Type Description
url
string

The absolute URL to the sign-in page