You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The initial connection is working fine with the generated access token which has a TTL of 60 minutes, but when I try to use to same access token with multiple calls to the same API and trying to establish a connection for the same, I am getting this error.
I am able to establish a connection after 9-10 tries, which takes around a time of 3-4 minutes after continuous retries
The code I am using to establish the connection,
func (i *imapUtils) ConnectAndReturnClient(clientAddress string, email string, userAccountsUUID string) (*client.Client, error) {
c, err := client.DialTLS(clientAddress, nil)
if err != nil {
i.log.Error("error in dialing client: ", err)
return nil, err
}
userAccountsCredentials, err := i.userAccountCredentialsRepo.GetByAccountUUID(userAccountsUUID)
if err != nil {
i.log.Error("error in credential details for ConnectAndReturnClient: ", err)
}
saslClient := sasl.NewOAuthBearerClient(&sasl.OAuthBearerOptions{
Username: email,
Token: userAccountsCredentials.AccessToken,
})
// giving a time interval before connecting for other connection
if *countPointer > 0 {
time.Sleep(time.Second * 10)
} else {
*countPointer += 1
}
err = c.Authenticate(saslClient)
if err != nil {
if err.Error() == domain.ErrOauthBeararAccess { // error handloinig for oAuth bearer
usvc := useraccountcredentials.New(i.cfg, i.log)
_, err := usvc.RegenerateAccessToken(userAccountsUUID) //Function to regenerate token
if err != nil {
i.log.Error("unable to regenerate access token ", userAccountsUUID, err)
return nil, err
} // error handling for new token
time.Sleep(time.Second * 10) // sleep time before re-trying
return i.ConnectAndReturnClient(clientAddress, email, userAccountsUUID) // check here
}
return nil, err
}
i.log.Info("Auth done.....")
*countPointer = 0
return c, nil
}
The text was updated successfully, but these errors were encountered:
The initial connection is working fine with the generated access token which has a TTL of 60 minutes, but when I try to use to same access token with multiple calls to the same API and trying to establish a connection for the same, I am getting this error.
I am able to establish a connection after 9-10 tries, which takes around a time of 3-4 minutes after continuous retries
The code I am using to establish the connection,
func (i *imapUtils) ConnectAndReturnClient(clientAddress string, email string, userAccountsUUID string) (*client.Client, error) {
c, err := client.DialTLS(clientAddress, nil)
if err != nil {
i.log.Error("error in dialing client: ", err)
return nil, err
}
userAccountsCredentials, err := i.userAccountCredentialsRepo.GetByAccountUUID(userAccountsUUID)
if err != nil {
i.log.Error("error in credential details for ConnectAndReturnClient: ", err)
}
saslClient := sasl.NewOAuthBearerClient(&sasl.OAuthBearerOptions{
Username: email,
Token: userAccountsCredentials.AccessToken,
})
// giving a time interval before connecting for other connection
if *countPointer > 0 {
time.Sleep(time.Second * 10)
} else {
*countPointer += 1
}
err = c.Authenticate(saslClient)
if err != nil {
if err.Error() == domain.ErrOauthBeararAccess { // error handloinig for oAuth bearer
usvc := useraccountcredentials.New(i.cfg, i.log)
_, err := usvc.RegenerateAccessToken(userAccountsUUID) //Function to regenerate token
if err != nil {
i.log.Error("unable to regenerate access token ", userAccountsUUID, err)
return nil, err
} // error handling for new token
time.Sleep(time.Second * 10) // sleep time before re-trying
return i.ConnectAndReturnClient(clientAddress, email, userAccountsUUID) // check here
}
return nil, err
}
i.log.Info("Auth done.....")
*countPointer = 0
return c, nil
}
The text was updated successfully, but these errors were encountered: