@@ -283,8 +283,13 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
283283 }
284284 cn .Inited = true
285285
286+ var err error
286287 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 {
288293 username , password = c .opt .CredentialsProvider ()
289294 }
290295
@@ -300,7 +305,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
300305
301306 // for redis-server versions that do not support the HELLO command,
302307 // 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 {
304309 auth = true
305310 } else if ! isRedisError (err ) {
306311 // 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 {
313318 return err
314319 }
315320
316- _ , err : = conn .Pipelined (ctx , func (pipe Pipeliner ) error {
321+ _ , err = conn .Pipelined (ctx , func (pipe Pipeliner ) error {
317322 if ! auth && password != "" {
318323 if username != "" {
319324 pipe .AuthACL (ctx , username , password )
0 commit comments