demo

package module
v0.0.0-...-210a1b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

README

Shared Contact Admin (SCA)

A web based application for administering Google Apps Domain Shared Contacts.

This is a Google App Engine (GAE) application written in Golang that provides a web based user interface for importing, exporting and deleting Google Apps shared contacts. It is based on the Google Domain Shared Contacts API:

https://developers.google.com/admin-sdk/domain-shared-contacts/

What is Domain Shared Contacts API?

The Shared Contacts API allows client applications to retrieve and update external contacts that are shared to all users in a Google Apps domain. Shared contacts are visible to all users of an Apps domain and all Google services have access to the contact list. To retrieve and update Google Apps domain users contact information, use the Directory API instead.

The Domain Shared Contacts API is only available to Google Apps for Business and Education accounts. The contacts sharing is disabled by default and this can be enabled by the Admin of the domain.

API Features

http://developers.google.com/admin-sdk/domain-shared-contacts/#Creating

  • [OK] Creating shared contacts
  • [OK] Retrieving shared contacts
  • Retrieving shared contacts using query parameters
  • Retrieving a single shared contact
  • Retrieving a photo for a contact
  • [OK] Updating shared contacts
  • Shared contact photo management
  • [OK] Deleting shared contacts Batch operations

** [OK] means SCA is now supporting these functionalities

Build Instructions

For specific GAE setup, please read first the documentation:

https://cloud.google.com/appengine/docs/go/

Prepare

go get golang.org/x/oauth2 go get golang.org/x/oauth2/google go get google.golang.org/appengine go get google.golang.org/appengine/urlfetch

Detailed Steps

Donwload & Install SCA

  1. Download installer zip file
  2. Unzip all files under "shared-contacts-admin-master" folder
  3. Take note of the file "oauth.go" which contains authentication details
  • Note that the ClientID and ClientSecret can be configured on https://console.cloud.google.com
  • Since there are multiple settings to be done in Developers Console and Google Apps, they will be covered separately
  • For now, don't change anything yet on the oauth.go, we will try to compile & upload first to appengine
    var (
        config = &oauth2.Config{
            ClientID:     `?????????-??????????.apps.googleusercontent.com`,
            ClientSecret: `?????????????`,
            RedirectURL:  `ideally-should-be-set-later`,
            Scopes:       []string{`http://www.google.com/m8/feeds/contacts/`},
            Endpoint:     google.Endpoint,
        }
    
        yeah = "yeah"
    )
  1. Create an appengine project on https://console.cloud.google.com
  • Take note of the email address and project ID
  1. Open a command prompt & upload app to appengine
  2. Execute upload and compile command to appengine
  • appcfg.py --application=PROJ_ID --email=EMAIL@EMAIL.COM --no_cookies update shared-contacts-admin-master
  1. After successful upload, try the website URL
  • http://PROJECT-ID.appspot.com
  • The Imports section - This is where you can Import Contacts
  • The Exports Section - This is where you can Export Contacts
  • The Delete Section - This is where you can Delete Contacts
  1. Now you have working URL but it is not yet usable...
  • As expected, there will be errors when you try the SCA as is...
  • What needs to be done so we can make use of this app? We need to setup Google Developer Console and also we need to setup Google Apps for Work

Setup Google Developer Console (Part 1)

  • Enable Contacts API
  • The API Credentials - contains Open Auth 2.0 client ID/secret
  • Add the following redirect URIs (replace with your project ID): Blockquote
http://g-apps-sca001.appspot.com/contacts/export
http://g-apps-sca001.appspot.com/import/do
http://g-apps-sca001.appspot.com/contacts/exportxml
http://g-apps-sca001.appspot.com/contacts/delete
  • Put the client ID and client secret in the oauth.go program
  • Update Consent screen

Setup Google Apps for Work/Education

  • Go to Google Apps http://apps.google.com as admin
  • Go to Users to configure contacts sharing
  • Click admin user
  • Click to show Google apps enabled
  • Click to configure contacts
  • Click to go to advanced settings
  • Enable options for Contacts Sharing

Setup Google Developer Console (Part 2)

  • Manage Service Accounts
  • Select App Engine service account
  • Enable Google Apps Domain-Wide Delegation
  • Notice that a new client has been created automatically for the service account

APIs and Google Apps settings done!

  • Now recompile Go project and upload to appengine

Using the SCA

1. Importing contacts from CSV

  • Go to the Imports section
  • Point to CSV file and Enter Google Apps Domain
  • Results will show successful imports

2. Exporting contacts to CSV

  • Go to Exports Section
  • Enter Google Apps Domain
  • CSV File will be downloaded
  • Open the exported excel file

3. Exporting contacts to XML

  • Go to Exports Section
  • Enter Google Apps domain name
  • XML file will be downloaded
  • Open the exported XML file

4. Deleting Contacts

  • Go to the Delete Contacts section
  • Enter Google Apps domain
  • Results will show batch delete request

Viewing the Shared Contacts

  1. Visit Contacts https://contacts.google.com (as admin)
  • Click on the Directory
  • Contacts are now visible on the domain

Documentation

Index

Constants

View Source
const (
	NUM_COLUMNS              int = 129
	ACTION_COL_IDX           int = 0
	ID_COL_IDX               int = 1
	NAME_COL_IDX             int = 2
	COMPANY_COL_IDX          int = 3
	JOBTITLE_COL_IDX         int = 4
	NOTES_COL_IDX            int = 5
	CATEGORIES_COL_IDX       int = 6
	CONTACTTYPE_COL_IDX      int = 7
	DOMAIN_COL_IDX           int = 8
	APIID_COL_IDX            int = 9
	WORKRELTYPE_COL_IDX      int = 10
	BIRTHDAY_COL_IDX         int = 11
	HOMERELTYPE_COL_IDX      int = 12
	OTHERRELTYPE_COL_IDX     int = 13
	MOBILERELTYPE_COL_IDX    int = 14
	NAMELOWER_COL_IDX        int = 15
	NAMELOWERUNIQUE_COL_IDX  int = 16
	NICKNAME_COL_IDX         int = 17
	EXTERNALID_COL_IDX       int = 18
	OCCUPATION_COL_IDX       int = 19
	DEPARTMENT_COL_IDX       int = 20
	JOBDESCRIPTION_COL_IDX   int = 21
	IM_COL_IDX               int = 22
	IMREL_COL_IDX            int = 23
	WEBSITE_COL_IDX          int = 24
	WEBSITEREL_COL_IDX       int = 25
	RELATION_COL_IDX         int = 26
	RELATIONREL_COL_IDX      int = 27
	CUSTOMKEY1_COL_IDX       int = 28
	CUSTOMVALUE1_COL_IDX     int = 29
	CUSTOMKEY2_COL_IDX       int = 30
	CUSTOMVALUE2_COL_IDX     int = 31
	CUSTOMKEY3_COL_IDX       int = 32
	CUSTOMVALUE3_COL_IDX     int = 33
	CUSTOMKEY4_COL_IDX       int = 34
	CUSTOMVALUE4_COL_IDX     int = 35
	CUSTOMKEY5_COL_IDX       int = 36
	CUSTOMVALUE5_COL_IDX     int = 37
	CUSTOMKEY6_COL_IDX       int = 38
	CUSTOMVALUE6_COL_IDX     int = 39
	BUSINESSFAX_COL_IDX      int = 40
	BUSINESSPHONE_COL_IDX    int = 41
	BUSINESSPHONE2_COL_IDX   int = 42
	HOMEFAX_COL_IDX          int = 43
	HOMEPHONE_COL_IDX        int = 44
	HOMEPHONE2_COL_IDX       int = 45
	OTHERPHONE_COL_IDX       int = 46
	MOBILEPHONE_COL_IDX      int = 47
	PAGER_COL_IDX            int = 48
	HOMEADDRESS_COL_IDX      int = 49
	BUSINESSADDRESS_COL_IDX  int = 50
	OTHERADDRESS_COL_IDX     int = 51
	E_MAILADDRESS_COL_IDX    int = 52
	E_MAIL2ADDRESS_COL_IDX   int = 53
	E_MAIL3ADDRESS_COL_IDX   int = 54
	E_MAIL4ADDRESS_COL_IDX   int = 55
	E_MAIL5ADDRESS_COL_IDX   int = 56
	E_MAIL6ADDRESS_COL_IDX   int = 57
	E_MAIL7ADDRESS_COL_IDX   int = 58
	E_MAIL8ADDRESS_COL_IDX   int = 59
	E_MAIL9ADDRESS_COL_IDX   int = 60
	E_MAIL10ADDRESS_COL_IDX  int = 61
	E_MAIL11ADDRESS_COL_IDX  int = 62
	E_MAIL12ADDRESS_COL_IDX  int = 63
	E_MAIL13ADDRESS_COL_IDX  int = 64
	E_MAIL14ADDRESS_COL_IDX  int = 65
	E_MAIL15ADDRESS_COL_IDX  int = 66
	E_MAIL16ADDRESS_COL_IDX  int = 67
	E_MAIL17ADDRESS_COL_IDX  int = 68
	E_MAIL18ADDRESS_COL_IDX  int = 69
	E_MAIL19ADDRESS_COL_IDX  int = 70
	E_MAIL20ADDRESS_COL_IDX  int = 71
	E_MAIL21ADDRESS_COL_IDX  int = 72
	E_MAIL22ADDRESS_COL_IDX  int = 73
	E_MAIL23ADDRESS_COL_IDX  int = 74
	E_MAIL24ADDRESS_COL_IDX  int = 75
	E_MAIL25ADDRESS_COL_IDX  int = 76
	E_MAIL26ADDRESS_COL_IDX  int = 77
	E_MAIL27ADDRESS_COL_IDX  int = 78
	E_MAIL28ADDRESS_COL_IDX  int = 79
	E_MAIL29ADDRESS_COL_IDX  int = 80
	E_MAIL30ADDRESS_COL_IDX  int = 81
	E_MAIL31ADDRESS_COL_IDX  int = 82
	E_MAIL32ADDRESS_COL_IDX  int = 83
	E_MAIL33ADDRESS_COL_IDX  int = 84
	E_MAIL34ADDRESS_COL_IDX  int = 85
	E_MAIL35ADDRESS_COL_IDX  int = 86
	E_MAIL36ADDRESS_COL_IDX  int = 87
	E_MAIL37ADDRESS_COL_IDX  int = 88
	E_MAIL38ADDRESS_COL_IDX  int = 89
	E_MAIL39ADDRESS_COL_IDX  int = 90
	E_MAIL40ADDRESS_COL_IDX  int = 91
	E_MAIL41ADDRESS_COL_IDX  int = 92
	E_MAIL42ADDRESS_COL_IDX  int = 93
	E_MAIL43ADDRESS_COL_IDX  int = 94
	E_MAIL44ADDRESS_COL_IDX  int = 95
	E_MAIL45ADDRESS_COL_IDX  int = 96
	E_MAIL46ADDRESS_COL_IDX  int = 97
	E_MAIL47ADDRESS_COL_IDX  int = 98
	E_MAIL48ADDRESS_COL_IDX  int = 99
	E_MAIL49ADDRESS_COL_IDX  int = 100
	E_MAIL50ADDRESS_COL_IDX  int = 101
	E_MAIL51ADDRESS_COL_IDX  int = 102
	E_MAIL52ADDRESS_COL_IDX  int = 103
	E_MAIL53ADDRESS_COL_IDX  int = 104
	E_MAIL54ADDRESS_COL_IDX  int = 105
	E_MAIL55ADDRESS_COL_IDX  int = 106
	E_MAIL56ADDRESS_COL_IDX  int = 107
	E_MAIL57ADDRESS_COL_IDX  int = 108
	E_MAIL58ADDRESS_COL_IDX  int = 109
	E_MAIL59ADDRESS_COL_IDX  int = 110
	E_MAIL60ADDRESS_COL_IDX  int = 111
	E_MAIL61ADDRESS_COL_IDX  int = 112
	E_MAIL62ADDRESS_COL_IDX  int = 113
	E_MAIL63ADDRESS_COL_IDX  int = 114
	E_MAIL64ADDRESS_COL_IDX  int = 115
	E_MAIL65ADDRESS_COL_IDX  int = 116
	E_MAIL66ADDRESS_COL_IDX  int = 117
	E_MAIL67ADDRESS_COL_IDX  int = 118
	E_MAIL68ADDRESS_COL_IDX  int = 119
	E_MAIL69ADDRESS_COL_IDX  int = 120
	WEBSITEHOME_PAGE_COL_IDX int = 121
	WEBPAGE_COL_IDX          int = 122
	WEBSITEBLOG_COL_IDX      int = 123
	WEBSITEPROFILE_COL_IDX   int = 124
	WEBSITEHOME_COL_IDX      int = 125
	WEBSITEWORK_COL_IDX      int = 126
	WEBSITEOTHER_COL_IDX     int = 127
	WEBSITEFTP_COL_IDX       int = 128
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppState

type AppState struct {
	Domain string `json:"domain"`
}

type Entry

type Entry struct {
	Title   string    `xml:"title"`
	Id      string    `xml:"id"`
	ETag    string    `xml:"http://schemas.google.com/g/2005 etag,attr"`
	Link    []Link    `xml:"link"`
	Content string    `xml:"content"`
	Updated time.Time `xml:"updated" datastore:",noindex"`
	//	Author                  Person                      `xml:"author"`
	//	Summary                 Text                        `xml:"summary"`
	Name                    GDName                      `xml:"http://schemas.google.com/g/2005 name"`
	Im                      []GDIm                      `xml:"http://schemas.google.com/g/2005 im"`
	Email                   []GDEmail                   `xml:"http://schemas.google.com/g/2005 email"`
	PhoneNumber             []GDPhoneNumber             `xml:"http://schemas.google.com/g/2005 phoneNumber"`
	Organization            GDOrganization              `xml:"http://schemas.google.com/g/2005 organization"`
	StructuredPostalAddress []GDStructuredPostalAddress `xml:"http://schemas.google.com/g/2005 structuredPostalAddress"`
	ExtendedProperty        []GDExtendedProperty        `xml:"http://schemas.google.com/g/2005 extendedProperty"`
	ContactUDField          []GContactUDField           `xml:"http://schemas.google.com/contact/2008 userDefinedField"`
	ContactWebsite          []GContactWebsite           `xml:"http://schemas.google.com/contact/2008 website"`
	Birthday                GContactBirthday            `xml:"http://schemas.google.com/contact/2008 birthday"`
	Nickname                string                      `xml:"http://schemas.google.com/contact/2008 nickname"`
	ExternalId              []GContactExternalId        `xml:"http://schemas.google.com/contact/2008 externalId"`
	Occupation              string                      `xml:"http://schemas.google.com/contact/2008 occupation"`
}

type EntryArb

type EntryArb struct {
	Field []*Field
}

type Feed

type Feed struct {
	XMLName xml.Name  `xml:"http://www.w3.org/2005/Atom feed"`
	Title   string    `xml:"title"`
	Id      string    `xml:"id"`
	Link    []Link    `xml:"link"`
	Updated time.Time `xml:"updated,attr"`
	Author  Person    `xml:"author"`
	Entry   []Entry   `xml:"entry"`
}

type Field

type Field struct {
	Name  string
	Value string
}

type GContactBirthday

type GContactBirthday struct {
	When string `xml:"when,attr"`
}

type GContactExternalId

type GContactExternalId struct {
	Label string `xml:"label,attr"`
	Rel   string `xml:"rel,attr"`
	Value string `xml:"value,attr"`
}

type GContactUDField

type GContactUDField struct {
	Key   string `xml:"key,attr"`
	Value string `xml:"value,attr"`
}

type GContactWebsite

type GContactWebsite struct {
	Webref  string `xml:"href,attr"`
	Label   string `xml:"label,attr"`
	Primary bool   `xml:"primary,attr"`
	Rel     string `xml:"rel,attr"`
}

type GDEmail

type GDEmail struct {
	Address     string `xml:"address,attr"`
	Primary     bool   `xml:"primary,attr"`
	Label       string `xml:"label,attr"`
	Rel         string `xml:"rel,attr"`
	DisplayName string `xml:"displayName,attr"`
}

type GDExtendedProperty

type GDExtendedProperty struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type GDIm

type GDIm struct {
	Address  string `xml:"address,attr"`
	Protocol string `xml:"protocol,attr"`
	Primary  bool   `xml:"primary,attr"`
	Label    string `xml:"label,attr"`
	Rel      string `xml:"rel,attr"`
}

type GDName

type GDName struct {
	FullName       string `xml:"http://schemas.google.com/g/2005 fullName"`
	GivenName      string `xml:"http://schemas.google.com/g/2005 givenName"`
	FamilyName     string `xml:"http://schemas.google.com/g/2005 familyName"`
	AdditionalName string `xml:"http://schemas.google.com/g/2005 additionalName"`
	NamePrefix     string `xml:"http://schemas.google.com/g/2005 namePrefix"`
	NameSuffix     string `xml:"http://schemas.google.com/g/2005 nameSuffix"`
}

type GDOrganization

type GDOrganization struct {
	Label             string `xml:"label,attr"`
	Rel               string `xml:"rel,attr"`
	Primary           bool   `xml:"primary,attr"`
	OrgDepartment     string `xml:"http://schemas.google.com/g/2005 orgDepartment"`
	OrgJobDescription string `xml:"http://schemas.google.com/g/2005 orgJobDescription"`
	OrgName           string `xml:"http://schemas.google.com/g/2005 orgName"`
	OrgSymbol         string `xml:"http://schemas.google.com/g/2005 orgSymbol"`
	OrgTitle          string `xml:"http://schemas.google.com/g/2005 orgTitle"`
	Where             string `xml:"http://schemas.google.com/g/2005 where"`
}

type GDPhoneNumber

type GDPhoneNumber struct {
	PhoneNumber string `xml:",chardata"`
	Primary     bool   `xml:"primary,attr"`
	Label       string `xml:"label,attr"`
	Rel         string `xml:"rel,attr"`
	Uri         string `xml:"uri,attr"`
}

type GDStructuredPostalAddress

type GDStructuredPostalAddress struct {
	Primary          bool   `xml:"primary,attr"`
	City             string `xml:"city"`
	Street           string `xml:"street"`
	Region           string `xml:"region"`
	Postcode         string `xml:"postcode"`
	Country          string `xml:"country"`
	FormattedAddress string `xml:"formattedAddress"`
	Label            string `xml:"label,attr"`
	Rel              string `xml:"rel,attr"`
	MailClass        string `xml:"mailClass,attr"`
	Usage            string `xml:"usage,attr"`
}

type ImportData

type ImportData struct {
	Data []byte
}
type Link struct {
	Rel  string `xml:"rel,attr,omitempty"`
	Href string `xml:"href,attr"`
}

type Person

type Person struct {
	Name     string `xml:"name"`
	URI      string `xml:"uri"`
	Email    string `xml:"email"`
	InnerXML string `xml:",innerxml"`
}

type Text

type Text struct {
	Type string `xml:"type,attr,omitempty"`
	Body string `xml:",chardata"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL