Skip to content

Support OAuth flow for modules #2546

Open
@Julusian

Description

@Julusian

Is this a feature relevant to companion itself, and not a module?

  • I believe this to be a feature for companion, not a module

Is there an existing issue for this?

  • I have searched the existing issues

Describe the feature

Some modules use OAuth to authenticate against an API. This is done in varying ways, due to the complexities involved and it not fitting into our config model very well, as it involves navigating to a URL, and then storing a code that was returned.

The current recommended approach to OAuth is documented on the wiki: https://github.com/bitfocus/companion-module-base/wiki/OAuth

What can we do to simplify/streamline this for modules, to make the experience better for users?

Custom config field helper

A full approach could involve creating a new config field type, which would handle the abstraction of OAuth. It would handle showing/generation of all the necessary config fields for setting up OAuth, and provide them to the module as an object.

{
	type: 'oauth',
	id: 'myoauth',
	label: 'Authentication',
	width: 12,
	exchangeUrl: 'https://api.restream.io/oauth/token',
	authorizationUrl: 'https://api.restream.io/login',
	scopes: 'some scopes here',
},

with the resulting object looking like:

{
  clientId: '',
  clientSecret: '',
  accessToken: '',
  refreshToken: '',
}

As part of this component we could offer a button to open the completed authorizationUrl so that the user can go through the process.
We would also then handle receiving the code through a callback, and converting that into access and refresh tokens.

Some thought will need to go into the UX of this in the browser, and how that will work with saving the module config. But this would allow modules to massively simplify their OAuth usage, and make something that is consistent for the users.

Or keep it simpler with some other options to streamline some small portions:

A way for modules to 'open' a url for the user

Some modules are using open to open the authorizationUrl automatically for users. Perhaps we could provide a way for modules to request a url is opened for the user, which we can show as a prompt in the webui. That way it will work for users who are configuring remotely.

Usecases

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestNeeds beer!This needs discussion while drinking beerarea/guiGUI / Webapp relatedarea/module-apiModule related

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions