@@ -145,6 +145,17 @@ func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string {
145
145
return buf .String ()
146
146
}
147
147
148
+ // A PasswordCredentialOption is passed to Config.AuthCodeURL.
149
+ type PasswordCredentialOption interface {
150
+ setValue (url.Values )
151
+ }
152
+
153
+ // SetPasswordCredentialParam builds a PasswordCredentialToken which passes
154
+ // key/value parameters to a provider's authorization endpoint.
155
+ func SetPasswordCredentialParam (key , value string ) PasswordCredentialOption {
156
+ return setParam {key , value }
157
+ }
158
+
148
159
// PasswordCredentialsToken converts a resource owner username and password
149
160
// pair into a token.
150
161
//
@@ -156,13 +167,17 @@ func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string {
156
167
//
157
168
// The HTTP client to use is derived from the context.
158
169
// If nil, http.DefaultClient is used.
159
- func (c * Config ) PasswordCredentialsToken (ctx context.Context , username , password string ) (* Token , error ) {
160
- return retrieveToken ( ctx , c , url.Values {
170
+ func (c * Config ) PasswordCredentialsToken (ctx context.Context , username , password string , opts ... PasswordCredentialOption ) (* Token , error ) {
171
+ v := url.Values {
161
172
"grant_type" : {"password" },
162
173
"username" : {username },
163
174
"password" : {password },
164
175
"scope" : internal .CondVal (strings .Join (c .Scopes , " " )),
165
- })
176
+ }
177
+ for _ , opt := range opts {
178
+ opt .setValue (v )
179
+ }
180
+ return retrieveToken (ctx , c , v )
166
181
}
167
182
168
183
// Exchange converts an authorization code into a token.
0 commit comments