Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'protocol' option to AuthenticationClient and ManagementClient, defaulting to 'https' #99

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var PasswordlessAuthenticator = require('./PasswordlessAuthenticator');
var UsersManager = require('./UsersManager');
var TokensManager = require('./TokensManager');

var BASE_URL_FORMAT = 'https://%s';
var BASE_URL_FORMAT = '%s://%s';


/**
Expand All @@ -37,12 +37,14 @@ var BASE_URL_FORMAT = 'https://%s';
* var AuthenticationClient = require('auth0'). AuthenticationClient;
* var auth0 = new AuthenticationClient({
* domain: '{YOUR_ACCOUNT}.auth0.com',
* protocol: '{http OR https}',
* clientId: '{OPTIONAL_CLIENT_ID}'
* });
*
* @param {Object} options Options for the Authentication Client
* SDK.
* @param {String} options.domain AuthenticationClient server domain.
* @param {String} [options.protocol] AuthenticationClient server protocol, defaults to 'https'
* @param {String} [options.clientId] Default client ID.
*/
var AuthenticationClient = function (options) {
Expand All @@ -62,7 +64,7 @@ var AuthenticationClient = function (options) {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
},
baseUrl: util.format(BASE_URL_FORMAT, options.domain)
baseUrl: util.format(BASE_URL_FORMAT, options.protocol || 'https', options.domain)
};

if (options.telemetry !== false) {
Expand Down
8 changes: 5 additions & 3 deletions src/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var JobsManager = require('./JobsManager');
var TicketsManager = require('./TicketsManager');
var LogsManager = require('./LogsManager');

var BASE_URL_FORMAT = 'https://%s/api/v2';
var BASE_URL_FORMAT = '%s://%s/api/v2';


/**
Expand All @@ -43,12 +43,14 @@ var BASE_URL_FORMAT = 'https://%s/api/v2';
* var ManagementClient = require('auth0').ManagementClient;
* var auth0 = new ManagementClient({
* token: '{YOUR_API_V2_TOKEN}',
* domain: '{YOUR_ACCOUNT}.auth0.com'
* domain: '{YOUR_ACCOUNT}.auth0.com',
* protocol: '{http OR https}'
* });
*
* @param {Object} options Options for the ManagementClient SDK.
* @param {String} options.token API access token.
* @param {String} [options.domain] ManagementClient server domain.
* @param {String} [options.protocol] ManagementClient server protocol, defaults to 'https'
*/
var ManagementClient = function (options) {
if (!options || typeof options !== 'object') {
Expand All @@ -69,7 +71,7 @@ var ManagementClient = function (options) {
'User-agent': 'node.js/' + process.version.replace('v', ''),
'Content-Type': 'application/json'
},
baseUrl: util.format(BASE_URL_FORMAT, options.domain)
baseUrl: util.format(BASE_URL_FORMAT, options.protocol || 'https', options.domain)
};

if (options.telemetry !== false) {
Expand Down