2023-01-27 03:22:44 -08:00
|
|
|
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
2021-02-04 00:37:03 -08:00
|
|
|
|
2022-07-24 08:36:17 -07:00
|
|
|
const scopes = ['identity', 'edit', 'history', 'mysubreddits', 'read', 'save', 'submit'];
|
2021-02-04 00:37:03 -08:00
|
|
|
|
|
|
|
// https://github.com/reddit-archive/reddit/wiki/OAuth2
|
|
|
|
|
|
|
|
export class RedditOAuth2Api implements ICredentialType {
|
|
|
|
name = 'redditOAuth2Api';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-07-24 08:36:17 -07:00
|
|
|
extends = ['oAuth2Api'];
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-02-04 00:37:03 -08:00
|
|
|
displayName = 'Reddit OAuth2 API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-02-04 00:37:03 -08:00
|
|
|
documentationUrl = 'reddit';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2022-06-13 22:27:19 -07:00
|
|
|
{
|
|
|
|
displayName: 'Grant Type',
|
|
|
|
name: 'grantType',
|
|
|
|
type: 'hidden',
|
|
|
|
default: 'authorizationCode',
|
|
|
|
},
|
2021-02-04 00:37:03 -08:00
|
|
|
{
|
|
|
|
displayName: 'Auth URI Query Parameters',
|
|
|
|
name: 'authQueryParameters',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'response_type=code',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Auth URI Query Parameters',
|
|
|
|
name: 'authQueryParameters',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'grant_type=authorization_code',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Auth URI Query Parameters',
|
|
|
|
name: 'authQueryParameters',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'duration=permanent',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Authorization URL',
|
|
|
|
name: 'authUrl',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'https://www.reddit.com/api/v1/authorize',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Access Token URL',
|
|
|
|
name: 'accessTokenUrl',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'https://www.reddit.com/api/v1/access_token',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Scope',
|
|
|
|
name: 'scope',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: scopes.join(' '),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Authentication',
|
|
|
|
name: 'authentication',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'hidden',
|
2021-02-04 00:37:03 -08:00
|
|
|
default: 'header',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|