# Adding a basic Authentication to my pm.sendrequest function

**URL:** <https://community.postman.com/t/adding-a-basic-authentication-to-my-pm-sendrequest-function/14975>\
**Category:** Help Hub\
**Tags:** authentication\
**Created:** [August 12, 2020, 5:17pm UTC](https://community.postman.com/t/adding-a-basic-authentication-to-my-pm-sendrequest-function/14975 "2020-08-12T17:17:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachary.baker123](https://avatars.discourse-cdn.com/v4/letter/z/977dab/32.png) [@zachary.baker123](https://community.postman.com/u/zachary.baker123)\
**Post date:** [August 12, 2020, 5:17pm UTC](https://community.postman.com/t/adding-a-basic-authentication-to-my-pm-sendrequest-function/14975/1 "2020-08-12T17:17:21Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-help-category/38) before creating a new topic.**

I’m trying to add Basic Authentication to my pm.sendrequest function. Is there a good example of a setup for the different auth types for the pm.sendrequest function?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 12, 2020, 5:55pm UTC](https://community.postman.com/t/adding-a-basic-authentication-to-my-pm-sendrequest-function/14975/2 "2020-08-12T17:55:12Z")

</div>

This is a good resource for that:

> <https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990>

Maybe something like:

```auto
let options = {
  url: 'https://www.example.com',
  auth: {
    user: username,
    password: password
  }
}

pm.sendRequest(options, function (err, res) {
  if (err) {
    console.dir(err)
    return
  }
})

```
