CloudOAuth2Callback

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

Table of Contents

Constructor

new Homey.CloudOAuth2Callback(apiUrl)

Tutorials:
  • Tutorial: Drivers-Pairing-System-Views
Parameters:
Name Type Description
apiUrl string

The Api url of the service you want to login with

Example
let myOAuth2Callback = new Homey.CloudOAuth2Callback(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
    })
    .generate()  // Generate the url after the listeners are registered
    .catch( err => {
        // Log when generate() experiences an error.
        console.log(err);
    })

Methods

generate(callbackopt) → {Promise}

Generate the OAuth2 Callback. This is a shorthand method for ManagerCloud#generateOAuth2Callback

Parameters:
Name Type Attributes Description
callback genericCallbackFunction <optional>
Returns:
Type:
Promise

Events

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

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