CTAuth

node v18.11.0
version: 2.0.0
endpointsharetweet
var endpoint = require("@runkit/runkit/json-endpoint/1.0.0") var request = require("request") // peer dependency var requestPromise = require("request-promise") var jsonQuery = require('json-query') const {JSONPath} = require('jsonpath-plus'); var axios = require('axios');
endpoint(module.exports, async function(request) { const url = 'https://auth.us-central1.gcp.commercetools.com/oauth/token'; const data = 'grant_type=client_credentials&scope=manage_project:imagecon'; const auth = { username: 'lWyJvSKrmUbwGfSz8UN-9tHU', password: 'UwBddfzynLovKsCZJKy1mqReVn0WEGvN' }; var jsonResponse; try { var options = { method: 'POST', uri: url, auth:auth, form: { // Like <input type="text" name="name"> grant_type: 'client_credentials', scope: 'manage_project:imagecon' }, json: true // Automatically parses the JSON string in the response }; console.log('executing request'); jsonResponse = await requestPromise(options); console.log('executed request'); return jsonResponse; } catch(e) { console.log("Error getting auth"); console.log(e); return e; } } )
Loading…

no comments

    sign in to comment