// GetUserinfo retrieves the userinfo from the
// https://www.googleapis.com/oauth2/v1/userinfo?alt=json
// endpoint.
420990
func (apiutil *ClientUtil) GetUserinfo() (GoogleUserinfo, error) {
	resp, err := apiutil.Client.Get(GoogleAPIUserinfoURL)
	if err != nil {
		return GoogleUserinfo{}, err
	}

	bodyBytes, err := httputilmore.ResponseBody(resp)
	if err != nil {
		return GoogleUserinfo{}, err
	}

	userinfo := GoogleUserinfo{}
	err = json.Unmarshal(bodyBytes, &userinfo)
	if err == nil {
		apiutil.User = userinfo
	}
	return userinfo, err
}
548187
func (api UsersusernameorganizationsAPI) Get(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]

	orgMgr := organizationdb.NewManager(r)

	orgs, err := orgMgr.AllByUserChain(username)
	if err != nil {
		log.Error("Failed to load all organizations the user belongs to: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	type UserOrganizations struct {
		Member []string `json:"member"`
		Owner  []string `json:"owner"`
	}
	userOrgs := UserOrganizations{
		Member: []string{},
		Owner:  []string{},
	}

	availableScopes, _ := context.Get(r, "availablescopes").(string)
	scopes := oauth2.SplitScopeString(availableScopes)
	isAdmin := oauth2.CheckScopes([]string{"user:admin"}, scopes)

	// if not isAdmin filter out orgs our scopes have access to
	if !isAdmin {
		userOrgs.Member = filterOrgs(orgs, scopes)
	} else {
		userOrgs.Member = orgs
	}

	userOrgs.Owner, userOrgs.Member, err = orgMgr.SplitOwnedOrgs(userOrgs.Member, username)
	if err != nil {
		log.Error("Failed to sort organizations to owner and member: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
	}
	w.Header().Set("Content-type", "application/json")
	json.NewEncoder(w).Encode(&userOrgs)
}
451260
func (provider *GithubProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, githubEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
925785
func (c *Client) GetInfo() (*Info, error) {
	r := c.NewRequest("GET", "/v2/info")
	resp, err := c.DoRequest(r)
	if err != nil {
		return nil, errors.Wrap(err, "Error requesting info")
	}
	defer resp.Body.Close()
	var i Info
	err = json.NewDecoder(resp.Body).Decode(&i)
	if err != nil {
		return nil, errors.Wrap(err, "Error unmarshalling info")
	}
	return &i, nil
}
474845
func (op *OpenIDProvider) UserInfo(accessToken string) (*UserInfo, error) {
	req, _ := http.NewRequest("GET", op.Config.UserInfoEndpoint, nil)
	req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", accessToken))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return nil, errors.Annotate(err, "Couldn't connect to the user info endpoint")
	}
	defer resp.Body.Close()
	decoder := json.NewDecoder(resp.Body)
	userInfo := &UserInfo{}
	err = decoder.Decode(userInfo)
	if err != nil {
		return nil, errors.Annotate(err, "Couldn't decode the token response")
	}
	return userInfo, nil
}
1277070
func (c *Crowd) GetUser(user string) (User, error) {
	u := User{}

	v := url.Values{}
	v.Set("username", user)
	url := c.url + "rest/usermanagement/1/user?" + v.Encode()
	c.Client.Jar = c.cookies
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return u, err
	}
	req.SetBasicAuth(c.user, c.passwd)
	req.Header.Set("Accept", "application/xml")
	req.Header.Set("Content-Type", "application/xml")
	resp, err := c.Client.Do(req)
	if err != nil {
		return u, err
	}
	defer resp.Body.Close()

	switch resp.StatusCode {
	case 404:
		return u, fmt.Errorf("user not found")
	case 200:
		// fall through switch without returning
	default:
		return u, fmt.Errorf("request failed: %s", resp.Status)
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return u, err
	}

	err = xml.Unmarshal(body, &u)
	if err != nil {
		return u, err
	}

	return u, nil
}
653179
func GetUserMetadata(ctx context.Context) (*UserMetadata, bool) {
	userMD := ctx.Value(userMDKey{})

	switch md := userMD.(type) {
	case *UserMetadata:
		return md, true
	default:
		return nil, false
	}
}
205095
func (c *Cache) GetUser(name string) (user services.User, err error) {
	u, err := c.usersCache.GetUser(name)
	if trace.IsNotFound(err) {
		return c.Users.GetUser(name)
	}
	return u, err
}
989304
func (s *service) RetrieveUserInfoByUserId(userId uint) (resDTO rest.ResponseDTOUserInfo, error *servicehelper.Error) {
	entity, err := s.repo.FindByID(userId)
	if err != nil {
		return rest.ResponseDTOUserInfo{}, &servicehelper.Error{Detail: errors.New("no result found"), Code: servicehelper.NotFound}
	}
	return rest.ResponseDTOUserInfo{
		UserId: entity.ID,
		Email:  entity.Email,
	}, nil
}
4818
func (s *ObjectsClient) GetInfo(ctx context.Context, input *GetInfoInput) (*GetInfoOutput, error) {
	absPath := absFileInput(s.client.AccountName, input.ObjectPath)

	headers := &http.Header{}
	for key, value := range input.Headers {
		headers.Set(key, value)
	}

	reqInput := client.RequestInput{
		Method:  http.MethodHead,
		Path:    string(absPath),
		Headers: headers,
	}
	_, respHeaders, err := s.client.ExecuteRequestStorage(ctx, reqInput)
	if err != nil {
		return nil, errors.Wrap(err, "unable to get info")
	}

	response := &GetInfoOutput{
		ContentType: respHeaders.Get("Content-Type"),
		ContentMD5:  respHeaders.Get("Content-MD5"),
		ETag:        respHeaders.Get("Etag"),
	}

	lastModified, err := time.Parse(time.RFC1123, respHeaders.Get("Last-Modified"))
	if err == nil {
		response.LastModified = lastModified
	}

	contentLength, err := strconv.ParseUint(respHeaders.Get("Content-Length"), 10, 64)
	if err == nil {
		response.ContentLength = contentLength
	}

	metadata := map[string]string{}
	for key, values := range respHeaders {
		if strings.HasPrefix(key, "m-") {
			metadata[key] = strings.Join(values, ", ")
		}
	}
	response.Metadata = metadata

	return response, nil
}
552261
func (conn *Connection) GetAuthInfo(auth Auth) (*AuthInfoResponse, error) {
	authInfo := AuthInfoResponse{}
	sessUrl, err := buildUrl("_session")
	if err != nil {
		return nil, err
	}
	var headers = make(map[string]string)
	headers["Accept"] = "application/json"
	resp, err := conn.request("GET", sessUrl, nil, headers, auth)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	err = parseBody(resp, &authInfo)
	if err != nil {
		return nil, err
	}
	return &authInfo, nil
}
378578
func (c *Client) GetUser(p *GetUserParameter) (*User, error) {
	obj, err := c.Request("getUser", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*User), err
}
580236
func (us *UsersService) GetAuthenticated() (*User, *http.Response, error) {
	u, err := urlWithOptions("/users/", nil)
	if err != nil {
		return nil, nil, err
	}

	req, err := us.client.NewRequest("GET", u, nil, nil)
	if err != nil {
		return nil, nil, err
	}

	var userResp getUserResponse
	resp, err := us.client.Do(req, &userResp)
	if err != nil {
		return nil, resp, err
	}

	return &userResp.User, resp, err
}
527917
func (s *Service) OAuthAuthorizationInfo(ctx context.Context, oauthAuthorizationIdentity string) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, s.Get(ctx, &oauthAuthorization, fmt.Sprintf("/oauth/authorizations/%v", oauthAuthorizationIdentity), nil, nil)
}
424636
func (a *AuthServer) GetUser(name string) (user services.User, err error) {
	return a.GetCache().GetUser(name)
}
1241220
func (w *WebHookAuthor) GetUsername() string {
	if w == nil || w.Username == nil {
		return ""
	}
	return *w.Username
}
475994
func (_m *FacadeInterface) GetUser(ctx datastore.Context, userName string) (user.User, error) {
	ret := _m.Called(ctx, userName)

	var r0 user.User
	if rf, ok := ret.Get(0).(func(datastore.Context, string) user.User); ok {
		r0 = rf(ctx, userName)
	} else {
		r0 = ret.Get(0).(user.User)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, string) error); ok {
		r1 = rf(ctx, userName)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}