How to open browser with NTLM auth

209 views
Skip to first unread message

shirok...@gmail.com

unread,
Oct 23, 2019, 1:20:27 AM10/23/19
to golang-nuts

I'm trying emulate browser, open intranet url and get status code 401. How to open url with NTLM auth or login, pass? Thanks

package main

import (
    "gopkg.in/headzoo/surf.v1"
        "fmt"
)

func main() {
    bow := surf.NewBrowser()
    bow.AddRequestHeader("Accept", "text/html")
    bow.AddRequestHeader("Accept-Charset", "utf8")
    err := bow.Open(url)
    if err != nil {
        panic(err)
    }

    fmt.Println(bow.StatusCode())
}

Skip Tavakkolian

unread,
Oct 23, 2019, 2:11:23 AM10/23/19
to shirok...@gmail.com, golang-nuts
Googling for "NTLM http go client", the first result looks legit:



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/faaa1b45-7516-447c-8397-fa9c16cc549c%40googlegroups.com.

shirok...@gmail.com

unread,
Oct 28, 2019, 10:21:24 PM10/28/19
to golang-nuts
When I use go-ntlmssp I get error 401. Try use curl curl --ntlm -u: url, get 200

среда, 23 октября 2019 г., 9:11:23 UTC+3 пользователь Skip написал:
Googling for "NTLM http go client", the first result looks legit:



On Tue, Oct 22, 2019 at 10:20 PM <shirok...@gmail.com> wrote:

I'm trying emulate browser, open intranet url and get status code 401. How to open url with NTLM auth or login, pass? Thanks

package main

import (
    "gopkg.in/headzoo/surf.v1"
        "fmt"
)

func main() {
    bow := surf.NewBrowser()
    bow.AddRequestHeader("Accept", "text/html")
    bow.AddRequestHeader("Accept-Charset", "utf8")
    err := bow.Open(url)
    if err != nil {
        panic(err)
    }

    fmt.Println(bow.StatusCode())
}

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.

Skip Tavakkolian

unread,
Oct 29, 2019, 12:30:39 PM10/29/19
to shirok...@gmail.com, golang-nuts
the code is working, but the user/pass are incorrect. user param may need the domain name (i.e. "DOMAIN\\username")
curl uses the stored credentials, which are usually created when user signs in or unlocks a session.


To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/778568c7-a746-41c3-be8b-386d5a91239c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages