Giter Club home page Giter Club logo

axios-ntlm's Introduction

Axios-NTLM

This is a helper library for NTLM Authentication using the Axios HTTP library on Node. It attaches interceptors to an axios instance to authenticate using NTLM for any resources that offer it.

Examples

Basic example

This example will create you a brand new axios instance you can utilise the same as any other axios instance

import { NtlmClient } from 'axios-ntlm';

(async () => {

    let credentials: NtlmCredentials = {
        username: 'username',
        password: "password",
        domain: 'domain'
    }

    let client = NtlmClient(credentials)

    try {
        let resp = await client({
            url: 'https://protected.site.example.com',
            method: 'get'
        });
        console.log(resp.data);
    }
    catch (err) {
        console.log(err)
        console.log("Failed")
    }

})()

With a custom Axios config

This shows how to pass in an axios config in the same way that you would when setting up any other axios instance.

Note: If doing this, be aware that http(s)Agents need to be attached to keep the connection alive. If there are none attached already, they will be added. If you are providing your own then you will need to set this up.

import { AxiosRequestConfig } from 'axios';
import { NtlmClient, NtlmCredentials } from 'axios-ntlm';

(async () => {
    
    let credentials: NtlmCredentials = {
        username: 'username',
        password: "password",
        domain: 'domain'
    }

    let config: AxiosRequestConfig = {
        baseURL: 'https://protected.site.example.com',
        method: 'get'
    }

    let client = NtlmClient(credentials, config)

    try {
        let resp = await client.get('/api/123')
        console.log(resp);
    }
    catch (err) {
        console.log(err)
        console.log("Failed")
    }

})()

axios-ntlm's People

Contributors

catbuttes avatar arontsang avatar caspergreen avatar xaviermonin avatar dependabot[bot] avatar vision10 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.