Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
podio-api-client
lib
modules
File Content:
Authentication.js
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const HttpClient_1 = __importDefault(require("../http/HttpClient")); const index_1 = require("../utils/index"); class Authentication { /** * * @param AppCredentials */ constructor(appCredentials) { this.access_token = ''; this.refresh_token = ''; this.expires_in = 0; this.token_type = ''; this.scope = ''; this.ref = {}; this.appCredentials = appCredentials; } /** * Authentication response * * @returns AuthToken */ AuthToken() { const { access_token, refresh_token, scope, token_type, ref, expires_in } = this; return { access_token, refresh_token, scope, token_type, ref, expires_in, }; } /** * Podio app authentication flow * @param app_id * @param app_token * @returns */ appAuth(app_id, app_token) { return __awaiter(this, void 0, void 0, function* () { /** * Define request data object */ const requestData = Object.assign({ grant_type: 'app', app_id, app_token }, this.appCredentials); /** * Handle request and return with the response */ let { data } = yield this._httpRequest(requestData); let AuthToken = data; this._updateAuthToken(AuthToken); return this.AuthToken(); }); } /** * Podio username & password flow * @param username * @param password * @returns */ passwordAuth(username, password) { return __awaiter(this, void 0, void 0, function* () { /** * Define request data object */ const requestObj = Object.assign({ grant_type: 'password', username, password }, this.appCredentials); /** * Handle request and return with the response */ let { data } = yield this._httpRequest(requestObj); let AuthToken = data; this._updateAuthToken(AuthToken); return this.AuthToken(); }); } /** * Podio server side flow * * * First, perform the server side flow and get the authorization code from call back * use the code to complete the server side authentication flow * @param code * @param redirect_uri * @returns */ authenticateWithAuthCode(code, redirect_uri) { return __awaiter(this, void 0, void 0, function* () { /** * Define request data object */ const requestObj = Object.assign({ grant_type: 'authorization_code', code, redirect_uri }, this.appCredentials); /** * Handle request and return with the response */ let { data } = yield this._httpRequest(requestObj); let AuthToken = data; this._updateAuthToken(AuthToken); return this.AuthToken(); }); } /** * Re issue the access token using the refresh * @param refresh_token * @returns */ authenticateWithRefreshToken(refresh_token) { return __awaiter(this, void 0, void 0, function* () { /** * Define request data object */ const requestObj = Object.assign({ grant_type: 'refresh_token', refresh_token }, this.appCredentials); /** * Handle request and return with the response */ let { data } = yield this._httpRequest(requestObj); let AuthToken = data; this._updateAuthToken(AuthToken); return this.AuthToken(); }); } /** * Update authentication response to the properties * * @param {AuthToken} response */ _updateAuthToken(response) { this.access_token = response.access_token; this.refresh_token = response.refresh_token; this.scope = response.scope; this.token_type = response.token_type; this.ref = response.ref; this.expires_in = response.expires_in; } /** * Initialize HttpClient class with the request config * Send the http request and return the response * @param data * @returns */ _httpRequest(data) { return __awaiter(this, void 0, void 0, function* () { /** * * @type {string} queryData */ let queryData = (0, index_1.generateQueryString)(data); return yield new HttpClient_1.default({ method: 'post', url: '/oauth/token', data: queryData, headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }).call(); }); } } exports.default = Authentication;
Edit
Download
Unzip
Chmod
Delete