Git Product home page Git Product logo

nspostman's Introduction

nspostman

This is a pre-request script for use with Postman and the Netsapiens platform

The following requires the use of Postman from https://www.postman.com/ and your Netsapiens instance

Instructions

Under your Netsapiens collection, right click and then Edit

Under Authorization

Set Type: OAuth 2.0 Add auth data to: Request Headers Access Token: {{accessToken}} Header Prefix: Bearer

Pre-request Scripts

let fqdn = pm.variables.get('fqdn');
let clientid = pm.variables.get('clientid');
let clientsecret = pm.variables.get('clientsecret');
let username = pm.variables.get('username');
let password = pm.variables.get('password');

let tokenUrl = 'https://' + fqdn + '/ns-api/oauth2/token/?';
let getTokenRequest = {
    method: 'POST',
    url: tokenUrl,
    body: {
        mode: 'formdata',
        formdata: [
            { key: 'grant_type', value: 'password' },
            { key: 'client_id', value: clientid },
            { key: 'client_secret', value: clientsecret },
            { key: 'username', value: username },
            { key: 'password', value: password }
        ]
    }
};

pm.sendRequest(getTokenRequest, (err, response) => {
    let jsonResponse = response.json(),
        newAccessToken = jsonResponse.access_token;

    console.log({ err, jsonResponse, newAccessToken })

    pm.environment.set('accessToken', newAccessToken);
    pm.variables.set('accessToken', newAccessToken);
    pm.environment.set('access_token', newAccessToken);
});```
## Variables
Add the following variables

fqdn = The FQDN of your portal server
clientid = Your ClientID
clientsecret = Your Client Secret
username = Your portal user name
let password = Your portal password

![Example Images](https://imgur.com/a/cSJmUDQ)

nspostman's People

Contributors

oitray avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.