OAuth and Conditional Requests

17 views
Skip to first unread message

Graham Lyons

unread,
Apr 23, 2018, 4:47:14 AM4/23/18
to go-github
The documentation for this library mentions authentication (https://github.com/google/go-github#authentication) and conditional requests (https://github.com/google/go-github#conditional-requests).

Is it possible to use conditional requests whilst authenticated? It seems that each relies on supplying an HTTP Transport so I can't see how it would be possible but I'd very much like to be wrong.

Thanks,
Graham

Graham Lyons

unread,
Apr 23, 2018, 11:33:18 AM4/23/18
to go-github
I got this to work by following the Custom HTTP section of the OAuth documentation: https://godoc.org/golang.org/x/oauth2#example-Config--CustomHTTP

I was surprised that it worked because the NewClient docs say that the custom HTTP client is only used for fetching a token: https://godoc.org/golang.org/x/oauth2#NewClient

"Note that if a custom *http.Client is provided via the Context it is used only for token acquisition and is not used to configure the *http.Client returned from NewClient."

This line does suggest however that the provided client is used: https://github.com/golang/oauth2/blob/038cb4a/transport.go#L48

Anyway, the effect on my API call limit is clear and discussions around the OAuth2 library aren't for this forum.
Reply all
Reply to author
Forward
0 new messages