// SetRefreshTokenExpiration sets the RefreshTokenExpiration field's value.
16206
func (s *Credentials) SetRefreshTokenExpiration(v time.Time) *Credentials {
	s.RefreshTokenExpiration = &v
	return s
}
1333996
func (o *OIDCConnectorV2) SetExpiry(expires time.Time) {
	o.Metadata.SetExpiry(expires)
}
863430
func (s *ServerCertificateMetadata) SetExpiration(v time.Time) *ServerCertificateMetadata {
	s.Expiration = &v
	return s
}
38681
func (a *OAuthStrategy) RefreshToken() string {
	a.mu.RLock()
	defer a.mu.RUnlock()

	return a.refreshToken
}
389342
func (c *CacheTTL) SetExpire(key string, data interface{}, ttl int64) error {
	if key == "" {
		return nil
	}

	c.itemsMu.Lock()
	defer c.itemsMu.Unlock()

	if data == nil {
		delete(c.items, key)
		return nil
	}

	// return oldest item when the cache reaches maximum size
	if len(c.deleteQueue) >= c.maxSize {
		c.deleteOldest()
	}

	item := eurekache.NewItem()
	item.SetExpire(ttl)
	item.Value = data
	c.items[key] = item
	c.deleteQueue = append(c.deleteQueue, key)
	return nil
}
675090
func (u *UserV2) SetExpiry(expires time.Time) {
	u.Metadata.SetExpiry(expires)
}
520838
func (s *Activation) SetExpired(v bool) *Activation {
	s.Expired = &v
	return s
}
250536
func (t *tokenWithProvider) refreshTokenWithRetries(ctx context.Context, prev, base *internal.Token) (tok *internal.Token, err error) {
	err = retry.Retry(ctx, transient.Only(retryParams), func() error {
		tok, err = t.provider.RefreshToken(ctx, prev, base)
		return err
	}, nil)
	return
}
446453
func (c *Client) RefreshToken(refreshToken string) (*Token, error) {
	params := make(url.Values)
	params.Set("grant_type", GrantTypeRefreshToken)
	params.Set("refresh_token", refreshToken)
	params.Set("scope", "")
	return c.grantToken(params)
}
1022079
func (r *RedisStorer) ResetExpiry(key string) error {
	return r.client.Expire(key, r.maxAge).Err()
}
1298738
func (m *Manager) getRefreshToken(token string) (rt *refreshToken, err error) {
	rt = &refreshToken{}

	err = m.getRefreshTokenCollection().Find(bson.M{"refreshtoken": token}).One(rt)
	if err == mgo.ErrNotFound {
		rt = nil
		err = nil
	}
	if err != nil {
		rt = nil
	}

	return
}
177184
func (c *Client) GrantNewAccessTokenFromRefreshToken(refreshToken string) (*TokenResponse, error) {
	type request struct {
		GrantType    string `json:"grant_type"`
		RefreshToken string `json:"refresh_token"`
	}

	token := &TokenResponse{}

	req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/identity/openidconnect/tokenservice"), request{GrantType: "refresh_token", RefreshToken: refreshToken})
	if err != nil {
		return token, err
	}

	if err = c.SendWithAuth(req, token); err != nil {
		return token, err
	}

	return token, nil
}
631946
func (s *CompleteMultipartUploadOutput) SetExpiration(v string) *CompleteMultipartUploadOutput {
	s.Expiration = &v
	return s
}
1053111
func (s *HlsInputSettings) SetRetryInterval(v int64) *HlsInputSettings {
	s.RetryInterval = &v
	return s
}
622558
func (s *PutObjectOutput) SetExpiration(v string) *PutObjectOutput {
	s.Expiration = &v
	return s
}
1149109
func NewRefreshTokenSource(config *oauth2.Config, refreshToken string) oauth2.TokenSource {
	var noInitialToken *oauth2.Token = nil
	return oauth2.ReuseTokenSource(noInitialToken, config.TokenSource(
		oauth2.NoContext, // TODO: maybe accept a context later.
		&oauth2.Token{RefreshToken: refreshToken},
	))
}
1217608
func (m *tokenManager) GenerateUserTokenUsingRefreshToken(ctx context.Context, refreshTokenString string,
	identity *repository.Identity, permissions []Permissions) (*oauth2.Token, error) {

	nowTime := time.Now().Unix()
	unsignedAccessToken, err := m.GenerateUnsignedUserAccessTokenFromRefreshToken(ctx, refreshTokenString, identity)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	if permissions != nil && len(permissions) > 0 {
		claims := unsignedAccessToken.Claims.(jwt.MapClaims)
		claims["permissions"] = permissions
	}

	accessToken, err := unsignedAccessToken.SignedString(m.userAccountPrivateKey.Key)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	unsignedRefreshToken, err := m.GenerateUnsignedUserRefreshToken(ctx, refreshTokenString, identity)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	refreshToken, err := unsignedRefreshToken.SignedString(m.userAccountPrivateKey.Key)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	var nbf int64

	token := &oauth2.Token{
		AccessToken:  accessToken,
		RefreshToken: refreshToken,
		Expiry:       time.Unix(nowTime+m.config.GetAccessTokenExpiresIn(), 0),
		TokenType:    "Bearer",
	}

	// Derivative OAuth2 claims "expires_in" and "refresh_expires_in"
	extra := make(map[string]interface{})
	extra["expires_in"] = m.config.GetAccessTokenExpiresIn()
	extra["refresh_expires_in"] = m.config.GetRefreshTokenExpiresIn()
	extra["not_before_policy"] = nbf

	token = token.WithExtra(extra)

	return token, nil
}