Skip to content

Commit 1543b59

Browse files
authored
Merge pull request #179 from StalkR/unbreak-proxy-support
auth: remove contextwithHTTPClient
2 parents 40fdc53 + 6d24f9f commit 1543b59

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

auth/auth.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package spotifyauth
22

33
import (
44
"context"
5-
"crypto/tls"
65
"errors"
76
"net/http"
87
"os"
@@ -140,17 +139,6 @@ func New(opts ...AuthenticatorOption) *Authenticator {
140139
return a
141140
}
142141

143-
// contextWithHTTPClient returns a context with a value set to override the oauth2 http client as Spotify does not
144-
// support HTTP/2
145-
//
146-
// see: https://github.com/zmb3/spotify/issues/20
147-
func contextWithHTTPClient(ctx context.Context) context.Context {
148-
tr := &http.Transport{
149-
TLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},
150-
}
151-
return context.WithValue(ctx, oauth2.HTTPClient, &http.Client{Transport: tr})
152-
}
153-
154142
// ShowDialog forces the user to approve the app, even if they have already done so.
155143
// Without this, users who have already approved the app are immediately redirected to the redirect uri.
156144
var ShowDialog = oauth2.SetAuthURLParam("show_dialog", "true")
@@ -180,17 +168,17 @@ func (a Authenticator) Token(ctx context.Context, state string, r *http.Request,
180168
if actualState != state {
181169
return nil, errors.New("spotify: redirect state parameter doesn't match")
182170
}
183-
return a.config.Exchange(contextWithHTTPClient(ctx), code, opts...)
171+
return a.config.Exchange(ctx, code, opts...)
184172
}
185173

186174
// Exchange is like Token, except it allows you to manually specify the access
187175
// code instead of pulling it out of an HTTP request.
188176
func (a Authenticator) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) {
189-
return a.config.Exchange(contextWithHTTPClient(ctx), code, opts...)
177+
return a.config.Exchange(ctx, code, opts...)
190178
}
191179

192180
// Client creates a *http.Client that will use the specified access token for its API requests.
193181
// Combine this with spotify.HTTPClientOpt.
194182
func (a Authenticator) Client(ctx context.Context, token *oauth2.Token) *http.Client {
195-
return a.config.Client(contextWithHTTPClient(ctx), token)
183+
return a.config.Client(ctx, token)
196184
}

0 commit comments

Comments
 (0)