// GetUserIdentityContext will retrieve user info available per identity scopes with a custom context
196392
func (api *Client) GetUserIdentityContext(ctx context.Context) (*UserIdentityResponse, error) {
	values := url.Values{
		"token": {api.token},
	}
	response := &UserIdentityResponse{}

	err := api.postMethod(ctx, "users.identity", values, response)
	if err != nil {
		return nil, err
	}

	if err := response.Err(); err != nil {
		return nil, err
	}

	return response, nil
}
711802
func NewContext(ctx context.Context, idt *Identity) context.Context {
	return context.WithValue(ctx, idtKey, idt)
}
396189
func (o *GetIdentityIDParams) WithContext(ctx context.Context) *GetIdentityIDParams {
	o.SetContext(ctx)
	return o
}
59731
func IsUserPresent(ctx context.Context) bool {
	userIdentity := ctx.Value(UserIdentityKey)
	return userIdentity != nil && userIdentity != ""

}
133180
func GetOAuthTokenContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, err error) {
	response, err := GetOAuthResponseContext(ctx, client, clientID, clientSecret, code, redirectURI)
	if err != nil {
		return "", "", err
	}
	return response.AccessToken, response.Scope, nil
}
1000236
func (client *BaseClient) GetClientContext(
	settings *InvokeSettings) (context *ClientContext) {
	context = client.contextPool.Get().(*ClientContext)
	context.InitBaseContext()
	context.Client = client
	context.Retried = 0
	if client.UserData != nil {
		for k, v := range client.UserData {
			context.SetInterface(k, v)
		}
	}
	if settings == nil {
		context.InvokeSettings = InvokeSettings{
			Timeout: client.timeout,
			Retry:   client.retry,
		}
	} else {
		if settings.userData != nil {
			for k, v := range settings.userData {
				context.SetInterface(k, v)
			}
		}
		context.InvokeSettings = *settings
		if settings.Timeout <= 0 {
			context.Timeout = client.timeout
		}
		if settings.Retry <= 0 {
			context.Retry = client.retry
		}
	}
	return context
}
1196463
func (api *Client) GetUserPresenceContext(ctx context.Context, user string) (*UserPresence, error) {
	values := url.Values{
		"token": {api.token},
		"user":  {user},
	}

	response, err := api.userRequest(ctx, "users.getPresence", values)
	if err != nil {
		return nil, err
	}
	return &response.UserPresence, nil
}
782544
func (c *Client) IdentityGet(id string) (*models.Identity, error) {
	params := policy.NewGetIdentityIDParams().WithID(id).WithTimeout(api.ClientTimeout)

	resp, err := c.Policy.GetIdentityID(params)
	if err != nil {
		return nil, Hint(err)
	}
	return resp.Payload, nil
}
1057245
func FromContextGetUser(ctx context.Context) (*User, bool) {
	user, ok := ctx.Value(userContextKey).(*User)
	return user, ok
}
1338547
func NewMockContext(si msp.SigningIdentity) *MockContext {
	ctx := MockContext{
		MockProviderContext: NewMockProviderContext(),
		SigningIdentity:     si,
	}
	return &ctx
}
700338
func SetIdentity(r *http.Request, v string) *http.Request {
	return r.WithContext(context.WithValue(r.Context(), identity, v))
}
737177
func (api *Client) GetUserProfile(userID string, includeLabels bool) (*UserProfile, error) {
	return api.GetUserProfileContext(context.Background(), userID, includeLabels)
}
825837
func (c *Client) GetIdentity(accessToken string) (resp GetIdentityResponse, err error) {
	if accessToken == "" {
		return resp, errors.New("/identity/get - access token must be specified")
	}

	jsonBody, err := json.Marshal(getIdentityRequest{
		ClientID:    c.clientID,
		Secret:      c.secret,
		AccessToken: accessToken,
	})

	if err != nil {
		return resp, err
	}

	err = c.Call("/identity/get", jsonBody, &resp)
	return resp, err
}
811917
func (s *userServiceImpl) UserInfo(ctx context.Context, identityID uuid.UUID) (*repository.User, *repository.Identity, error) {
	var identity *repository.Identity
	err := s.ExecuteInTransaction(func() error {
		var err error
		identity, err = s.Repositories().Identities().LoadWithUser(ctx, identityID)
		if err != nil {
			return errors.NewUnauthorizedError(fmt.Sprintf("auth token contains id %s of unknown Identity\n", identityID))
		}
		return nil
	})

	if err != nil {
		return nil, nil, err
	}
	log.Debug(ctx, map[string]interface{}{
		"identity_id": identity.ID,
		"user_id":     identity.User.ID,
	}, "loaded identity and user")
	return &identity.User, identity, nil
}
896635
func setIdentityUser(identity *userapi.Identity, user *userapi.User) bool {
	if identityReferencesUser(identity, user) {
		return false
	}
	identity.User = corev1.ObjectReference{
		Name: user.Name,
		UID:  user.UID,
	}
	return true
}
1207247
func (c *Config) getContext() context.Context {
	client := &http.Client{
		Transport: util.NewRoundTripper(log.Get(), c.Client.ExtraHeaders),
	}

	return context.WithValue(context.Background(), oauth2.HTTPClient, client)
}
1172208
func unsetIdentityUser(identity *userapi.Identity) bool {
	if !hasUserMapping(identity) {
		return false
	}
	identity.User = corev1.ObjectReference{}
	return true
}