@@ -283,8 +283,13 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
283
283
}
284
284
cn .Inited = true
285
285
286
+ var err error
286
287
username , password := c .opt .Username , c .opt .Password
287
- if c .opt .CredentialsProvider != nil {
288
+ if c .opt .CredentialsProviderContext != nil {
289
+ if username , password , err = c .opt .CredentialsProviderContext (ctx ); err != nil {
290
+ return err
291
+ }
292
+ } else if c .opt .CredentialsProvider != nil {
288
293
username , password = c .opt .CredentialsProvider ()
289
294
}
290
295
@@ -300,7 +305,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
300
305
301
306
// for redis-server versions that do not support the HELLO command,
302
307
// RESP2 will continue to be used.
303
- if err : = conn .Hello (ctx , protocol , username , password , "" ).Err (); err == nil {
308
+ if err = conn .Hello (ctx , protocol , username , password , "" ).Err (); err == nil {
304
309
auth = true
305
310
} else if ! isRedisError (err ) {
306
311
// When the server responds with the RESP protocol and the result is not a normal
@@ -313,7 +318,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
313
318
return err
314
319
}
315
320
316
- _ , err : = conn .Pipelined (ctx , func (pipe Pipeliner ) error {
321
+ _ , err = conn .Pipelined (ctx , func (pipe Pipeliner ) error {
317
322
if ! auth && password != "" {
318
323
if username != "" {
319
324
pipe .AuthACL (ctx , username , password )
0 commit comments