当前位置: 首页>>代码示例>>Golang>>正文


Golang oauth2_client.OAuth2Client类代码示例

本文整理汇总了Golang中github.com/pomack/oauth2_client/go/oauth2_client.OAuth2Client的典型用法代码示例。如果您正苦于以下问题:Golang OAuth2Client类的具体用法?Golang OAuth2Client怎么用?Golang OAuth2Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OAuth2Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DeleteGroupOnExternalService

func DeleteGroupOnExternalService(client oauth2_client.OAuth2Client, cs ContactsService, ds DataStoreService, dsocialUserId, dsocialGroupId string) (bool, os.Error) {
	if dsocialGroupId == "" || dsocialUserId == "" {
		return false, nil
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return true, err
	}
	externalServiceId := cs.ServiceId()
	externalUserId := userInfo.Guid()
	externalGroupId, err := ds.ExternalGroupIdForDsocialId(externalServiceId, externalUserId, dsocialUserId, dsocialGroupId)
	if externalGroupId == "" || err != nil {
		return externalGroupId == "", err
	}
	externalGroup, _, err := ds.RetrieveExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
	if err != nil {
		return true, err
	}
	if externalGroup == nil {
		return false, err
	}
	_, err = cs.DeleteGroupOnExternalService(client, externalGroup)
	if err != nil {
		return true, err
	}
	_, err = ds.DeleteDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
	if err != nil {
		return true, err
	}
	_, err = ds.DeleteExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
	return true, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:32,代码来源:service.go

示例2: RetrieveContacts

func (p *SmugMugContactService) RetrieveContacts(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Contact, NextToken, os.Error) {
	l := list.New()
	var useErr os.Error
	famResp, err := smugmug.RetrieveFamily(client, nil)
	if err != nil {
		useErr = err
	}
	if famResp != nil && famResp.Family != nil {
		for _, u := range famResp.Family {
			contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, u.NickName, &u)
			if contact != nil {
				l.PushBack(contact)
			}
			if err != nil && useErr == nil {
				useErr = err
			}
		}
	}
	if useErr != nil {
		return p.listToContacts(l), nil, useErr
	}
	fansResp, err := smugmug.RetrieveFans(client, nil)
	if err != nil {
		useErr = err
	}
	if fansResp != nil && fansResp.Fans != nil {
		for _, u := range fansResp.Fans {
			contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, u.NickName, &u)
			if contact != nil {
				l.PushBack(contact)
			}
			if err != nil && useErr == nil {
				useErr = err
			}
		}
	}
	if useErr != nil {
		return p.listToContacts(l), nil, useErr
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return p.listToContacts(l), nil, err
	}
	userResp, err := smugmug.RetrieveUserInfo(client, userInfo.Username(), nil)
	if err != nil {
		useErr = err
	}
	if userResp != nil {
		contact, err := p.handleRetrievedContact(client, ds, dsocialUserId, userResp.User.NickName, &userResp.User)
		if contact != nil {
			l.PushBack(contact)
		}
		if err != nil && useErr == nil {
			useErr = err
		}
	}
	return p.listToContacts(l), nil, useErr
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:58,代码来源:smugmug.go

示例3: HandleGenericOauthTestRequest

func HandleGenericOauthTestRequest(w http.ResponseWriter, req *http.Request, c oauth2_client.OAuth2Client, method, test_url_property, body string, useTemplate *template.Template) {
	props := getProperties()
	if req.Method == oauth2_client.POST {
		if err := req.ParseForm(); err != nil {
			w.Header().Set("Content-Type", "text/plain")
			w.WriteHeader(500)
			io.WriteString(w, "Unable to parse form:\n\n")
			io.WriteString(w, err.Error())
			return
		}
		for k, arr := range req.Form {
			for _, v := range arr {
				props.Set(k, v)
			}
		}
	}
	for k, arr := range req.URL.Query() {
		for _, v := range arr {
			props.Set(k, v)
		}
	}
	c.Initialize(props)
	uri := props.GetAsString(test_url_property)
	log.Printf("Client is: %T -> %#v", c, c)
	var reader io.Reader = nil
	if len(body) > 0 {
		reader = bytes.NewBufferString(body)
	}
	resp, _, err := oauth2_client.AuthorizedRequest(c, method, nil, uri, nil, reader)
	m := make(map[string]interface{})
	isError := false
	m["c"] = c
	m["url"] = uri
	if err != nil {
		m["output"] = err.Error()
		isError = true
	} else {
		b, err := httputil.DumpResponse(resp, true)
		if err != nil {
			m["output"] = err.Error()
			isError = true
		} else {
			m["output"] = string(b)
		}
	}
	if isError {
		w.Header().Set("Content-Type", "text/plain")
		w.WriteHeader(500)
	} else {
		w.Header().Set("Content-Type", "text/html")
		w.WriteHeader(200)
	}
	err = useTemplate.Execute(w, m)
	if err != nil {
		oauth2_client.LogErrorf("Error: %T %v", err, err)
	}
}
开发者ID:pomack,项目名称:oauth2_client.go,代码行数:57,代码来源:oauth2_client_tester.go

示例4: HandleGenericOauthRequest

func HandleGenericOauthRequest(c oauth2_client.OAuth2Client, w http.ResponseWriter, req *http.Request) {
	uri := c.GenerateRequestTokenUrl(jsonhelper.NewJSONObject())
	if len(uri) > 0 {
		w.Header().Set("Location", uri)
		w.WriteHeader(302)
	} else {
		w.WriteHeader(500)
	}
}
开发者ID:pomack,项目名称:oauth2_client.go,代码行数:9,代码来源:oauth2_client_tester.go

示例5: RetrieveGroups

func (p *YahooContactService) RetrieveGroups(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Group, NextToken, error) {
	var m url.Values
	m = make(url.Values)
	m.Add("count", "max")
	if next == nil {
	} else if start, ok := next.(int); ok {
		m.Add("start", strconv.Itoa(start))
	}
	resp, err := yahoo.RetrieveCategories(client, m)
	if resp == nil || resp.Categories.Categories == nil || len(resp.Categories.Categories) == 0 || err != nil {
		return make([]*Group, 0), nil, err
	}
	groups := make([]*Group, len(resp.Categories.Categories))
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr error = nil
	for i, yahooGroup := range resp.Categories.Categories {
		var externalGroupId string
		if yahooGroup.Id > 0 {
			externalGroupId = strconv.FormatInt(yahooGroup.Id, 10)
		}
		var origDsocialGroup *dm.Group = nil
		dsocialGroupId := ""
		if len(externalGroupId) > 0 {
			dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
			if err != nil {
				if useErr == nil {
					useErr = err
				}
				continue
			}
			if dsocialGroupId != "" {
				origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
				if err != nil {
					if useErr == nil {
						useErr = err
					}
					continue
				}
			} else {
				ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, &yahooGroup)
			}
		}
		var dsocialGroup *dm.Group = dm.YahooCategoryToDsocial(&yahooGroup, origDsocialGroup, dsocialUserId)
		groups[i] = &Group{
			ExternalServiceId: p.ServiceId(),
			ExternalUserId:    externalUserId,
			ExternalGroupId:   externalGroupId,
			DsocialUserId:     dsocialUserId,
			DsocialGroupId:    dsocialGroupId,
			Value:             dsocialGroup,
		}
	}
	return groups, nil, useErr
}
开发者ID:pomack,项目名称:dsocial.go,代码行数:56,代码来源:yahoo.go

示例6: CreateContactOnExternalService

func CreateContactOnExternalService(client oauth2_client.OAuth2Client, cs ContactsService, ds DataStoreService, dsocialUserId string, contact *dm.Contact) (*Contact, os.Error) {
	if contact == nil {
		return nil, nil
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return nil, err
	}
	externalServiceId := cs.ServiceId()
	externalUserId := userInfo.Guid()
	externalContactId, err := ds.ExternalContactIdForDsocialId(externalServiceId, externalUserId, dsocialUserId, contact.Id)
	if err != nil {
		return nil, err
	}
	if externalContactId != "" {
		originalContact, _, err := ds.RetrieveDsocialContact(dsocialUserId, contact.Id)
		if err != nil {
			return nil, err
		}
		return UpdateContactOnExternalService(client, cs, ds, dsocialUserId, originalContact, contact)
	}
	externalContact := cs.ConvertToExternalContact(contact, nil, dsocialUserId)
	externalContact, externalContactId, err = cs.CreateContactOnExternalService(client, externalContact)
	if err != nil {
		return nil, err
	}
	externalContactId2, err := ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, externalContact)
	if err != nil {
		return nil, err
	}
	fmt.Printf("[SERVICE]: extContactId: %s, extContactId2: %s\n", externalContactId, externalContactId2)
	if externalContactId2 != "" {
		externalContactId = externalContactId2
	}
	dsocialContactForExternal := cs.ConvertToDsocialContact(externalContact, contact, dsocialUserId)
	dsocialContactForExternal, err = ds.StoreDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId, dsocialContactForExternal)
	if err != nil {
		return nil, err
	}
	_, _, err = ds.StoreDsocialExternalContactMapping(externalServiceId, externalUserId, externalContactId, dsocialUserId, dsocialContactForExternal.Id)
	outContact := &Contact{
		ExternalServiceId: externalServiceId,
		ExternalUserId:    externalUserId,
		ExternalContactId: externalContactId,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactForExternal.Id,
		Value:             dsocialContactForExternal,
	}
	return outContact, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:50,代码来源:service.go

示例7: RetrieveContacts

func (p *YahooContactService) RetrieveContacts(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Contact, NextToken, error) {
	var m url.Values
	m = make(url.Values)
	m.Add("count", "max")
	if next == nil {
	} else if start, ok := next.(int); ok {
		m.Add("start", strconv.Itoa(start))
	}
	resp, err := yahoo.RetrieveContacts(client, m)
	if resp == nil || resp.Contacts.Contacts == nil || len(resp.Contacts.Contacts) == 0 || err != nil {
		return make([]*Contact, 0), nil, err
	}
	contacts := make([]*Contact, len(resp.Contacts.Contacts))
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr error = nil
	for i, yahooContact := range resp.Contacts.Contacts {
		externalContactId := strconv.FormatInt(yahooContact.Id, 10)
		dsocialContactId := ""
		var origDsocialContact *dm.Contact = nil
		if len(externalContactId) > 0 {
			dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, externalContactId)
			if err != nil {
				useErr = err
				continue
			}
			if dsocialContactId != "" {
				origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
				if err != nil {
					useErr = err
					continue
				}
			} else {
				ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, &yahooContact)
			}
		}
		dsocialContact := dm.YahooContactToDsocial(&yahooContact, origDsocialContact, dsocialUserId)
		contacts[i] = &Contact{
			ExternalServiceId: p.ServiceId(),
			ExternalUserId:    externalUserId,
			ExternalContactId: externalContactId,
			DsocialUserId:     dsocialUserId,
			DsocialContactId:  dsocialContactId,
			Value:             dsocialContact,
		}
	}
	return contacts, nil, useErr
}
开发者ID:pomack,项目名称:dsocial.go,代码行数:49,代码来源:yahoo.go

示例8: UpdateGroupOnExternalService

func UpdateGroupOnExternalService(client oauth2_client.OAuth2Client, cs ContactsService, ds DataStoreService, dsocialUserId string, originalGroup, group *dm.Group) (*Group, os.Error) {
	if group == nil || originalGroup == nil {
		return nil, nil
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return nil, err
	}
	externalServiceId := cs.ServiceId()
	externalUserId := userInfo.Guid()
	externalGroupId, err := ds.ExternalGroupIdForDsocialId(externalServiceId, externalUserId, dsocialUserId, originalGroup.Id)
	if err != nil {
		return nil, err
	}
	if externalGroupId == "" {
		return CreateGroupOnExternalService(client, cs, ds, dsocialUserId, group)
	}
	originalExternalGroup, _, err := ds.RetrieveExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
	if err != nil {
		return nil, err
	}
	latestExternalGroup := cs.ConvertToExternalGroup(group, originalExternalGroup, dsocialUserId)
	latestExternalGroup2, externalGroupId2, err := cs.UpdateGroupOnExternalService(client, originalExternalGroup, latestExternalGroup)
	if err != nil {
		return nil, err
	}
	if latestExternalGroup2 != nil {
		latestExternalGroup = latestExternalGroup2
	}
	if externalGroupId2 != "" {
		externalGroupId = externalGroupId2
	}
	latestDsocialGroupForExternal := cs.ConvertToDsocialGroup(latestExternalGroup, originalGroup, dsocialUserId)
	_, err = ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, latestExternalGroup)
	if err != nil {
		return nil, err
	}
	latestDsocialGroupForExternal, err = ds.StoreDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId, latestDsocialGroupForExternal)
	outGroup := &Group{
		ExternalServiceId: externalServiceId,
		ExternalUserId:    externalUserId,
		ExternalGroupId:   externalGroupId,
		DsocialUserId:     dsocialUserId,
		DsocialGroupId:    latestDsocialGroupForExternal.Id,
		Value:             latestDsocialGroupForExternal,
	}
	return outGroup, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:48,代码来源:service.go

示例9: UpdateContactOnExternalService

func UpdateContactOnExternalService(client oauth2_client.OAuth2Client, cs ContactsService, ds DataStoreService, dsocialUserId string, originalContact, contact *dm.Contact) (*Contact, os.Error) {
	if contact == nil || originalContact == nil {
		return nil, nil
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return nil, err
	}
	externalServiceId := cs.ServiceId()
	externalUserId := userInfo.Guid()
	externalContactId, err := ds.ExternalContactIdForDsocialId(externalServiceId, externalUserId, dsocialUserId, originalContact.Id)
	if err != nil {
		return nil, err
	}
	if externalContactId == "" {
		return CreateContactOnExternalService(client, cs, ds, dsocialUserId, contact)
	}
	originalExternalContact, _, err := ds.RetrieveExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId)
	if err != nil {
		return nil, err
	}
	latestExternalContact := cs.ConvertToExternalContact(contact, originalExternalContact, dsocialUserId)
	latestExternalContact2, externalContactId2, err := cs.UpdateContactOnExternalService(client, originalExternalContact, latestExternalContact)
	if err != nil {
		return nil, err
	}
	if latestExternalContact2 != nil {
		latestExternalContact = latestExternalContact2
	}
	if externalContactId2 != "" {
		externalContactId = externalContactId2
	}
	latestDsocialContactForExternal := cs.ConvertToDsocialContact(latestExternalContact, originalContact, dsocialUserId)
	_, err = ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, latestExternalContact)
	if err != nil {
		return nil, err
	}
	latestDsocialContactForExternal, err = ds.StoreDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId, latestDsocialContactForExternal)
	outContact := &Contact{
		ExternalServiceId: externalServiceId,
		ExternalUserId:    externalUserId,
		ExternalContactId: externalContactId,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  latestDsocialContactForExternal.Id,
		Value:             latestDsocialContactForExternal,
	}
	return outContact, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:48,代码来源:service.go

示例10: CreateGroupOnExternalService

func CreateGroupOnExternalService(client oauth2_client.OAuth2Client, cs ContactsService, ds DataStoreService, dsocialUserId string, group *dm.Group) (*Group, os.Error) {
	if group == nil {
		return nil, nil
	}
	userInfo, err := client.RetrieveUserInfo()
	if err != nil {
		return nil, err
	}
	externalServiceId := cs.ServiceId()
	externalUserId := userInfo.Guid()
	externalGroupId, err := ds.ExternalGroupIdForDsocialId(externalServiceId, externalUserId, dsocialUserId, group.Id)
	if err != nil {
		return nil, err
	}
	if externalGroupId != "" {
		originalGroup, _, err := ds.RetrieveDsocialGroup(dsocialUserId, group.Id)
		if err != nil {
			return nil, err
		}
		return UpdateGroupOnExternalService(client, cs, ds, dsocialUserId, originalGroup, group)
	}
	externalGroup := cs.ConvertToExternalGroup(group, nil, dsocialUserId)
	externalGroup, externalGroupId, err = cs.CreateGroupOnExternalService(client, externalGroup)
	if err != nil {
		return nil, err
	}
	externalGroupId, err = ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, externalGroup)
	if err != nil {
		return nil, err
	}
	dsocialGroupForExternal := cs.ConvertToDsocialGroup(externalGroup, group, dsocialUserId)
	dsocialGroupForExternal, err = ds.StoreDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId, dsocialGroupForExternal)
	if err != nil {
		return nil, err
	}
	_, _, err = ds.StoreDsocialExternalGroupMapping(externalServiceId, externalUserId, externalGroupId, dsocialUserId, dsocialGroupForExternal.Id)
	outGroup := &Group{
		ExternalServiceId: externalServiceId,
		ExternalUserId:    externalUserId,
		ExternalGroupId:   externalGroupId,
		DsocialUserId:     dsocialUserId,
		DsocialGroupId:    dsocialGroupForExternal.Id,
		Value:             dsocialGroupForExternal,
	}
	return outGroup, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:46,代码来源:service.go

示例11: RetrieveGroup

func (p *YahooContactService) RetrieveGroup(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, groupId string) (*Group, error) {
	resp, err := yahoo.RetrieveCategory(client, groupId, nil)
	if resp == nil || err != nil {
		return nil, err
	}
	yahooGroup := &resp.Category
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	useErr := err
	var externalGroupId string
	if yahooGroup.Id > 0 {
		externalGroupId = strconv.FormatInt(yahooGroup.Id, 10)
	}
	dsocialGroupId := ""
	var origDsocialGroup *dm.Group = nil
	if len(externalGroupId) > 0 {
		dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
		if err != nil {
			if useErr == nil {
				useErr = err
			}
		}
		if dsocialGroupId != "" {
			origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, yahooGroup)
		}
	}
	var dsocialGroup *dm.Group = dm.YahooCategoryToDsocial(yahooGroup, origDsocialGroup, dsocialUserId)
	group := &Group{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalGroupId:   externalGroupId,
		DsocialUserId:     dsocialUserId,
		DsocialGroupId:    dsocialGroupId,
		Value:             dsocialGroup,
	}
	return group, useErr
}
开发者ID:pomack,项目名称:dsocial.go,代码行数:43,代码来源:yahoo.go

示例12: RetrieveContact

func (p *YahooContactService) RetrieveContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string) (*Contact, error) {
	resp, err := yahoo.RetrieveContact(client, contactId, nil)
	if resp == nil || err != nil {
		return nil, err
	}
	yahooContact := &resp.Contact
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	useErr := err
	dsocialContactId := ""
	var origDsocialContact *dm.Contact = nil
	var externalContactId string
	if yahooContact.Id > 0 {
		externalContactId = strconv.FormatInt(yahooContact.Id, 10)
	}
	if len(externalContactId) > 0 {
		dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, contactId)
		if err != nil {
			useErr = err
		}
		if dsocialContactId != "" {
			origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, yahooContact)
		}
	}
	dsocialContact := dm.YahooContactToDsocial(yahooContact, origDsocialContact, dsocialUserId)
	contact := &Contact{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalContactId: externalContactId,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactId,
		Value:             dsocialContact,
	}
	return contact, useErr
}
开发者ID:pomack,项目名称:dsocial.go,代码行数:41,代码来源:yahoo.go

示例13: RetrieveGroup

func (p *GoogleContactService) RetrieveGroup(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, groupId string) (*Group, os.Error) {
	resp, err := google.RetrieveGroup(client, groupId, nil)
	if resp == nil || resp.Entry == nil || err != nil {
		return nil, err
	}
	googleGroup := resp.Entry
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	useErr := err
	externalGroupId := googleGroup.GroupId()
	dsocialGroupId := ""
	var origDsocialGroup *dm.Group = nil
	if len(externalGroupId) > 0 {
		dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
		if err != nil {
			if useErr == nil {
				useErr = err
			}
		}
		if dsocialGroupId != "" {
			origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, googleGroup)
		}
	}
	var dsocialGroup *dm.Group = dm.GoogleGroupToDsocial(googleGroup, origDsocialGroup, dsocialUserId)
	group := &Group{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalGroupId:   externalGroupId,
		DsocialUserId:     dsocialUserId,
		DsocialGroupId:    dsocialGroupId,
		Value:             dsocialGroup,
	}
	return group, useErr
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:40,代码来源:google.go

示例14: RetrieveContact

func (p *GoogleContactService) RetrieveContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string) (*Contact, os.Error) {
	googleContact, err := google.RetrieveContact(client, contactId, nil)
	if googleContact == nil || err != nil {
		return nil, err
	}
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	useErr := err
	dsocialContactId := ""
	var origDsocialContact *dm.Contact = nil
	externalContactId := googleContact.ContactId()
	if len(externalContactId) > 0 {
		dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, contactId)
		if err != nil {
			useErr = err
		}
		if dsocialContactId != "" {
			origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, googleContact)
		}
	}
	dsocialContact := dm.GoogleContactToDsocial(googleContact, origDsocialContact, dsocialUserId)
	contact := &Contact{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    googleContact.ContactUserId(),
		ExternalContactId: googleContact.ContactId(),
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactId,
		Value:             dsocialContact,
	}
	return contact, useErr
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:37,代码来源:google.go

示例15: handleRetrievedContact

func (p *FacebookContactService) handleRetrievedContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string, extContact *facebook.Contact) (contact *Contact, err os.Error) {
	if extContact == nil {
		return nil, nil
	}
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr os.Error = nil
	dsocialContactId := ""
	var origDsocialContact *dm.Contact = nil
	externalContactId := extContact.Id
	if len(externalContactId) > 0 {
		dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, contactId)
		if err != nil {
			useErr = err
		}
		if dsocialContactId != "" {
			origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, extContact)
		}
	}
	dsocialContact := dm.FacebookContactToDsocial(extContact, origDsocialContact, dsocialUserId)
	contact = &Contact{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalContactId: externalContactId,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactId,
		Value:             dsocialContact,
	}
	return contact, useErr
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:36,代码来源:facebook.go


注:本文中的github.com/pomack/oauth2_client/go/oauth2_client.OAuth2Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。