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
func (c*Client) SendWithAuth(req*http.Request, vinterface{}) error {
// c.Lock()c.mu.Lock()
// Note: Here we do not want to `defer c.Unlock()` because we need `c.Send(...)`// to happen outside of the locked section.ifc.Token!=nil {
if!c.tokenExpiresAt.IsZero() &&c.tokenExpiresAt.Sub(time.Now()) <RequestNewTokenBeforeExpiresIn {
// c.Token will be updated in GetAccessToken callif_, err:=c.GetAccessToken(req.Context()); err!=nil {
// c.Unlock()c.mu.Unlock()
returnerr
}
}
req.Header.Set("Authorization", "Bearer "+c.Token.Token)
}
// Unlock the client mutex before sending the request, this allows multiple requests// to be in progress at the same time.// c.Unlock()c.mu.Unlock()
returnc.Send(req, v)
}
Can we make this easier to use. This method doesn't fetch token automatically in case there is no token. Thank you.
The text was updated successfully, but these errors were encountered:
Can we make this easier to use. This method doesn't fetch token automatically in case there is no token. Thank you.
The text was updated successfully, but these errors were encountered: