Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/oauth2/clientcredentials: context values are not passed to oauth2 requests that retrieve tokens #33131

Open
yansal opened this issue Jul 16, 2019 · 3 comments · May be fixed by golang/oauth2#393
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@yansal
Copy link
Contributor

yansal commented Jul 16, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13beta1 linux/amd64

Does this issue reproduce with the latest release?

It does reproduce with the latest version of golang.org/x/oauth2. I guess this is an issue about this subrepository.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/yann/.cache/go-build"
GOENV="/home/yann/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="github.com/ulule/*"
GONOSUMDB="github.com/ulule/*"
GOOS="linux"
GOPATH="/home/yann/go"
GOPRIVATE="github.com/ulule/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/yann/sdk/go1.13beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/yann/sdk/go1.13beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/yann/z/facebook/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build659375516=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/iOdgycJZA4f

This example requires facebook credentials, but the bug does reproduce with any credential source.

What did you expect to see?

There are two requests, one for retrieving an oauth2 token, and the other to get the actual URL.

I expected the two requests to see the same context values, which would generate an output like

context value
context value

What did you see instead?

<nil>
context value

The context value is not passed to the first request.

@gopherbot gopherbot added this to the Unreleased milestone Jul 16, 2019
@FiloSottile FiloSottile added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jul 17, 2019
@FiloSottile
Copy link
Contributor

x/oauth2 doesn't have an owner at the moment, but we'd find a reviewer if you wanted to submit a CL.

@yansal
Copy link
Contributor Author

yansal commented Jul 17, 2019

@FiloSottile thank you, I'll try to implement a fix

yansal added a commit to yansal/oauth2-1 that referenced this issue Jul 17, 2019
The main motivation for this change is that TokenSource doesn't
support contexts. We would like to access values from an http.Request
context when we are doing the request that generates a new token.

At this stage, this change is just a POC. I'd like to gather reviews
about this approach. If this approach is OK, I'll probably improve docs
and add proper testing.

Fixes golang/go#33131
@gopherbot
Copy link

Change https://golang.org/cl/186637 mentions this issue: oauth2: add an optional interface to add Context support to TokenSource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants