2021-02-04 00:37:03 -08:00
|
|
|
import {
|
|
|
|
ICredentialType,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2021-02-04 00:37:03 -08:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
const scopes = [
|
|
|
|
'identity',
|
|
|
|
'edit',
|
|
|
|
'history',
|
|
|
|
'mysubreddits',
|
|
|
|
'read',
|
|
|
|
'save',
|
|
|
|
'submit',
|
|
|
|
];
|
|
|
|
|
|
|
|
// https://github.com/reddit-archive/reddit/wiki/OAuth2
|
|
|
|
|
|
|
|
export class RedditOAuth2Api implements ICredentialType {
|
|
|
|
name = 'redditOAuth2Api';
|
|
|
|
extends = [
|
|
|
|
'oAuth2Api',
|
|
|
|
];
|
|
|
|
displayName = 'Reddit OAuth2 API';
|
|
|
|
documentationUrl = 'reddit';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
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',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|