I am running WIN XP SP3, For the past few days (since January 1) I have been having BIG problems getting into all kinds of Google sites, including Gmail. Normally I would post this problem on a Google forum, but I can't get into their sites for posting, so I'm posting it here,
The problem was first noticed when trying to get into Gmail, which didn't show up. I could search for something in Google and get a search list, but none of the links ln the list would would work. I could not get into my iGoogle page either. In Firefox 3.0.5 I would always get a blank page, and in Internet Explorer 7 I would get 'Internet Explorer cannot display the webpage'. All other sites except for Google work fine. The problem is on my PC and my wife's laptop - we are both on the same router and modem (hers is a wi-fi connection). So I took out the router and connected the cable modem directly to my PC - problem remains. So I called my ISP. They said they tried using my user name to go to Google sites and had no problems, so they weren't much help. I then removed all the Google cookies in FF, and lo and behold - I had GMail and Google search OK. So I went to my wife's laptop and did the same thing, and I got Google search, but no Gmail. I went back to my PC, and closed the Gmail, and tried opening it up again - no luck. No Gmail. (By the way GMail notifier works -it shows that I have Gmail waiting.) I didn't find a virus or spyware (unlikely to have the same bug in 2 browsers on two computers.) I also tried a couple of Gmail proxy sites - no luck. So the situation now is: *Google Search - works *Gmail - can't get it. Had it immediately after I removed Google FF cookies, and when ISP told me to lower security settings in IE, and maybe another couple of times at random in last few days, but in general, no Gmail on either computer. *Google Maps - I get it, but can't get to the 'My Maps' feature in FF. I removed the cookies, and I can't get to the Google sign in page, In IE, where I didn't remove cookies, I can get to 'My Maps' *iGoogle - can't get to my page *Google Forums - can't get to a page from which I can post. *Google Earth - works fine I can Ping Google.com and Gmail, and get replies. Sounds like a connection problem at Google? My ISP says no, and proxy sites don't work. Has Google been monkeying around with new versions lately? If anyone has any suggestions, I would appreciate it.
Sewer run full version free download - Sewer Alligator Run, Sewer Alligator Run Pro, Poo Run Sewer, and many more programs.
Important: This document was written before 2012. The auth options described in this document (OAuth 1.0, AuthSub, and ClientLogin) have been officially deprecated as of April 20, 2012 and are no longer available. We encourage you to migrate to OAuth 2.0 as soon as possible.
The Google Sites Data API allows client applications to access, publish, and modify content within a Google Site.Your client application can also request a list of recent activity, fetch revision history, and download attachments.
In addition to providing some background on the capabilities of the Sites Data API, this guide provides examples for interacting with the APIusing the Python client library. For help setting up the client library, seeGetting Started with the Google Data Python Client Library. If you're interested inunderstanding more about the underlying protocol used by the Python client library to interact with the Sites API, please see theprotocol guide.
Audience
This document is intended for developers who want to write client applications that interact with Google Sitesusing the Google Data Python Client Library.
Getting started
To use the Python client library, you'll need Python 2.2+ and the modules listed on the DependencyModules wiki page. After downloading the client library,see Getting Started with the Google Data Python Library for help installing and using the client.
Running the sample
A full working sample is located in the
samples/sites subdirectory of the project's Mercurial repository(/samples/sites/sites_example.py).
Run the example as follows:
If the required flags are not provided, the app will prompt you to input those values. The sample allows the user to perform a number of operations whichdemonstrate how to use the Sites API. As such, you'll need to authenticate to perform certain operations (e.g. modifying content). The program willalso prompt you to authenticate via AuthSub, OAuth, orClientLogin.
To include the examples in this guide into your own code, you'll need the following
import statements:
You will also need to setup a
SitesClient object, which represents a client connection to the Sites API.Pass in your application's name and the webspace name of the Site (from its URL):
To work with a Site that is hosted on a G Suite domain, set the domain using the
domain parameter:
In the above snippets, the
source argument is optional but is recommended for logging purposes. It shouldfollow the format: company-applicationname-version
Note: The rest of the guide assumes you created a
SitesClient object in the variable client .
Authenticating to the Sites API
The Python client library can be used to work with either public or private feeds. The Sites Data API provides access to private and publicfeeds, depending on a Site's permissions and the operation you're trying to perform. For example, you may be able to read the content feed ofa public Site but not make updates to it - something that requires an authenticated client. This can be done viaClientLogin username/password authentication, AuthSub, orOAuth.
Please see the Google Data APIs Authentication Overview for more information on AuthSub, OAuth, and ClientLogin.
AuthSub for web applications
AuthSub Authentication for Web Applications should be used by client applications which need toauthenticate their users to Google or G Suite accounts. The operator does not need access to the username and password for the Google Sites user - only anAuthSub token is required.
View instructions for incorporating AuthSub into your web application
Request a single-use token
When the user first visits your application, they need to authenticate. Typically, developers print some text and a link directing the userto the AuthSub approval page to authenticate the user and request access to their documents. The Google Data Python client library provides a function,
generate_auth_sub_url() to generate this URL. The code below sets up a link to the AuthSubRequest page.
If you want to authenticate users on a G Suite hosted domain, pass in the domain name to
generate_auth_sub_url() :
The
generate_auth_sub_url() method takes several parameters (corresponding to the query parameters used by theAuthSubRequest handler):
Upgrading to a session token
See Using AuthSub with the Google Data API Client Libraries.
Retrieving information about a session token
See Using AuthSub with the Google Data API Client Libraries.
Revoking a session token
See Using AuthSub with the Google Data API Client Libraries.
Tip: Once your application has successfully acquired a long lived sessions token,store that token in your database to recall for later use. There's no need to send the user back to AuthSub on every run of your application.Use
client.auth_token = gdata.gauth.AuthSubToken(TOKEN_STR) to set an existing token on the client.
OAuth for web or installed/mobile applications
OAuth can be used as an alternative to AuthSub, and is intended for web applications.OAuth is similar to using the secure and registered mode of AuthSubin that all data requests must be digitally signed and you must register your domain.
View instructions for incorporating OAuth into your installed application
Fetching a request token
See Using OAuth with the Google Data API Client Libraries.
Authorizing a request token
See Using OAuth with the Google Data API Client Libraries.
Upgrading to an access token
See Using OAuth with the Google Data API Client Libraries.
Tip: Once your application has successfully acquired an OAuth access token,store that token in your database to recall for later use. There's no need to send the user back through OAuth on every run of your application.Use
client.auth_token = gdata.oauth.OAuthToken(TOKEN_STR, TOKEN_SECRET) to set an existing token on the client.
ClientLogin for installed/mobile applications
ClientLogin should be used by installed or mobile applications which need toauthenticate their users to Google accounts. On first run, your application prompts the user for their username/password. On subsequent requests,an authentication token is referenced.
View instructions for incorporating ClientLogin into your installed application
To use ClientLogin, invoke the
ClientLogin() method of SitesClient object, which is inherited fromGDClient . Specify the email address andpassword of the user on whose behalf your client is making requests. For example:
Tip: Once your application has successfully authenticated the user for the first time, store the auth token in your database to recall for later use. There's no need to prompt the user for their password on every run of your application.See Recalling an auth token for more information.
For more information on using ClientLogin in your Python applications, see the Using ClientLogin with the Google Data API Client Libraries.
Site Feed
The site feed can be used to list the Google Sites a user owns or has viewing permissions for.It can also be used to modify the name of an existing site. Lastly, for G Suite domains, it can also be used to create and/or copy anentire site.
Listing sites
To list the sites a user has access to, use the client's
GetSiteFeed() method. The method takes an optionalargument, uri , which you may use to specify an alternate site feed URI. By default, the GetSiteFeed() uses the site name and domain set on the client object. See the Getting Started section formore information on setting these values on your client object.
Here is an example of fetching the authenticated user's list of sites:
The above snippet prints the site's title, site name, site it was copied from, and its acl feed URI.
Creating new sites
Note: This feature is only available to G Suite domains.
New sites can be provisioned by calling the library's
CreateSite() method.Similar to the GetSiteFeed() helper, CreateSite() also accepts anoptional argument, uri , which you may use to specify an alternate site feed URI (in the case of creatingthe site under a different domain other than the one that's set on your SitesClient object).
Here is an example of creating a new site with the theme 'slate' and providing atitle and (optional) description:
The above request would create a new site under the G Suite domain
example2.com .Thus, the site's URL would be https://sites.google.com/a/example2.com/title-for-my-site.
If the site is successfully created, the server will respond with a
gdata.sites.data.SiteEntry object, populated with elements added by the server: a link to the site, a link to the site's acl feed,the site name, the title, summary, and so forth.
Copying a site
Note: This feature is only available to G Suite domains.
CreateSite() can also be used to copy an existing site. To do this, pass in the source_site keyword argument.Any site that's been copied will have this link, which is accessible via entry.FindSourceLink() . Here is an example of duplicating the sitecreated in the Creating new sites section:
Important points:
Updating a site's metadata
To update the title or summary of a site, you'll need a
SiteEntry containing the site in question. Thisexample uses the GetEntry() method to first fetch a SiteEntry , and then change its title, description and category tag:
Fetching the Activity Feed
Note: Access to this feed requires that you are a collaborator or owner of the Site.Your client must authenticate by using an AuthSub, OAuth, or ClientLogin token. See Authenticating to the Sites service.
You can fetch a Site's recent activity (changes) by fetching the activity feed.The lib's
GetActivityFeed() method provides access to this feed:
Calling
GetActivityFeed() returns a gdata.sites.data.ActivityFeed object containing a list ofgdata.sites.data.ActivityEntry . Each activity entry contains information ona change that was made to the Site.
Fetching Revision History
Note: Access to this feed requires that you are a collaborator or owner of the Site.Your client must authenticate by using an AuthSub, OAuth, or ClientLogin token. See Authenticating to the Sites service.
The revision feed provides information on the revision history for any content entry. The
GetRevisionFeed() method can be used to fetch the revisions for a given content entry. The method takes an optional uri parameter that accepts a gdata.sites.data.ContentEntry , a full URI of a content entry, or a content entry id.
This example queries the content feed, and fetches the revision feed for the first content entry:
Calling
GetRevisionFeed() returns a gdata.sites.data.RevisionFeed object containing a list ofgdata.sites.data.RevisionEntry . Each revision entry contains information such as the contentat that revision, the version number, and when the new version was created.
Content feedRetrieving the content feed
Note: The content feed may or may not require authentication; depending on the Site's sharing permissions.If the Site is non-public, your client must authenticate by using an AuthSub, OAuth, or ClientLogin token. SeeAuthenticating to the Sites service.
The content feed returns a Site's latest content. It can be accessed by calling the lib's
GetContentFeed() method, which takes an optional uri string parameter for passinga customized query.
Here is an example of fetching the entire content feed and printing out some interesting elements:
Tip: The
entry.Kind() can be used to determine an entry's type.
The resulting
feed object is a gdata.sites.data.ContentFeed containing a listof gdata.sites.data.ContentEntry . Each entry represents a different page/item withinthe user's Site and has elements specific to the kind of entry it is. See the sample application for a better ideaof some of the properties available in each entry kind.
Content feed query examples
You can search the content feed using some of the standard Google Data API query parametersand those specific to the Sites API. For more detailed information and a full list of supported parameters, see theReference Guide.
Note: The examples in this section make use of the
gdata.sites.client.MakeContentFeedUri() helper methodfor constructing the base URI of the content feed.
Retrieving specific entry kinds
To fetch only a particular type of entry, use the
kind parameter. As an example, this snippet returns just attachment entries:
To return more than one type, separate each
kind with a comma. For example, this snippet returns filecabinet andlistpage entries:
Retrieving a page by path
If you know the relative path of a page within the Google Site, you can use the
path parameter to fetch that particular page.This example would return the page located athttp://sites.google.com/domainName/siteName/path/to/the/page :
Retrieving all entries under a parent page
If you know the content entry id of a page (e.g. '1234567890' in the example below), you can use the
parent parameterto fetch all of its child entries (if any):
For additional parameters, see the Reference Guide.
Creating Content
Note: Before creating content for a site, ensure that you have set your site in the client.
client.site = 'siteName'
New content (webpages, listpages, filecabinets, announcementpages, etc.) can be created by using
CreatePage() .The first argument to this method should be the kind of page to create, followed by the title, and its HTML content.
For a list of supported node types, see the
kind parameter in the Reference Guide.
Creating new items / pages
This example creates a new
webpage under the top-level, includes some XHTML for the page body,and sets the heading title to 'New WebPage Title':
If the request is successful,
entry will contain a copy of the entry created on the server, as a gdata.sites.gdata.ContentEntry .
To create more complex entry kind that are populated on creation (e.g. a
listpage with column headings), you'll need to createthe gdata.sites.data.ContentEntry manually, fill in the properties of interest, and call client.Post() .
Creating items/pages under custom URL paths
By default, the previous example would be created under the URL
http://sites.google.com/domainName/siteName/new-webpage-title andhave a page heading of 'New Webpage Title'. That is, the title is normalized to new-webpage-title for the URL.To customize a page's URL path, you can set the page_name property on the content entry. The CreatePage() helperprovides this as an optional keyword argument.
This example creates a new
filecabinet page with a heading of 'File Storage', but creates the pageunder the URL http://sites.google.com/domainName/siteName/files (instead of http://sites.google.com/domainName/siteName/file-storage )by specifying the page_name property.
The server uses the following precedence rules for naming a page's URL path:
Creating subpages
To create subpages (children) under a parent page, use
CreatePage() 's parent keyword argument.The parent can either be a gdata.sites.gdata.ContentEntry or a string representing thecontent's entry's full self id.
This example queries the content feed for
announcementpage s and creates a new announcement under the first one that is found:
Uploading files
Just as in Google Sites, the API supports attachment uploads to a file cabinet page or parent page. Attachments must be uploadedto a parent page. Therefore, you must set a parent link on the
ContentEntry you're trying to upload. See Creating subpages for more information.
The client library's
UploadAttachment() method provides the interface for uploading attachments.
Uploading attachments
This example uploads a PDF file to the first
filecabinet found in the user's content feed.The attachment is created with a title of 'New Employee Handbook' and a (optional) description, 'HR packet'.
If the upload is successful,
attachment will contain a copy of the created attachment on the server.
Uploading an attachment to a folder
Filecabinets in Google Sites support folders. The
UploadAttachment() provides an additional keywordargument, folder_name that you can use to upload an attachment into a filecabinet folder. Simply specify that folder's name:
Notice that this example passes a
gdata.data.MediaSource object to UploadAttachment() insteadof a filepath. It also does not pass a content type. Instead, the content type is specified on the MediaSource object.
Web attachments
Web attachments are special kinds of attachments. Essentially, they're links to other files on the webthat you can add to your
filecabinet listings. This feature is analogous to the 'Add file by URL' upload method in the Google Sites UI.
Note: Web attachments can only be created under a
filecabinet . They cannot be uploaded to other types of pages.
This example creates a web attachment under the first
filecabinet found in the user's content feed.Its title and (optional) description are set to 'GoogleLogo' and 'nice colors', respectively.
The call creates a link pointing to the image at 'http://www.google.com/images/logo.gif' in the filecabinet .
Updating ContentUpdating a page's metadata and/or html content
The metadata (title, pageName, etc.) and page content of any entry kind can be edited byusing the client's
Update() method.
Below is an example of updating a
listpage with the following changes:
Replacing an attachment's content + metadata
You can replace an attachment's file content by creating a new MediaSource objectwith the new file content and calling the client's Update() method. The attachment'smetadata (such as title and description) can also be updated, or simply just the metadata.This example demonstrates updating file content and metadata at the same time:
Deleting Content
To remove a page or item from a Google Site, first retrieve the content entry, then call the client's
Delete() method.
You can also pass the
Delete() method the content entry's edit link and/or force the deletion:
For more information about ETags, see the Google Data APIs reference guide.
Downloading Attachments
Each
attachment entry contains a content src link which can be used to download the file contents.The Sites client contains a helper method for accessing and downloading the file from this link: DownloadAttachment() .It accepts a gdata.sites.data.ContentEntry or download URI for its first argument, and a filepath to save the attachmentto as the second.
This example fetches a particular attachment entry (by querying it's
self link) and downloads the file to the specified path:
It is up to the app developer to specify a file extension that makes sense for the attachment's content type. The content typecan be found in
entry.content.type .
In some cases you may not be able to download the file to disk (e.g. if your app is running in Google App Engine).For these situations, use
_GetFileContent() to fetch the file content and store it in memory.
This example download's an attachment to memory.
ACL FeedOverview of Sharing Permissions (ACLs)
Each ACL entry in the ACL feed represents an access role of a particular entity, either a user, a group of users, a domain,or the default access (which is a public site). Entries will only be shown for entities with explicit access - one entry will be shownfor each e-mail address in the 'People with Access' panel in the sharing screen of the Google Sites UI. Thus, domain admins will not be shown,even though they have implicit access to a site.
Roles
The role element represents an access level an entity can have. There are four possible values of the
gAcl:role element:
Scopes
The scope element represents the entity that has this access level. There are four possible types of the
gAcl:scope element:
Note: Domains cannot have a
gAcl:role valueset to 'owner' access, they can only be readers or writers.
Retrieving the ACL feed
The ACL feed can be used to control a site's sharing permissions and can be fetched using the
GetAclFeed() method.
The following example fetches the ACL feed for the site currently set on the
SitesClient object,and prints out the permission entries:
After a successful query,
feed will be a gdata.sites.data.AclFeed object containinga listing of gdata.sites.data.AclEntry .
If you're working with entries in the SiteFeed, each
SiteEntry contains a link to its ACL feed.For example, this snippet fetches the first site in the user's Site feed and queries its ACL feed:
Sharing a site
Note: Certain sharing ACLs may only be possible if the domain is configuredto allow such permissions (e.g. if sharing outside of the domain for G Suite domains is enabled, etc).
To share a Google Site using the API, create an
gdata.sites.gdata.AclEntry with the desiredgdata.acl.data.AclScope and gdata.acl.data.AclRole values. See theACL feed Overview section for the possible AclScope and AclRoles values.
This example grants read permissions on the Site to user '[email protected]':
Group and Domain level sharing
Similar to sharing a site with a single user, you can share a site across aGoogle group or G Suite domain. The necessary
scope values are listed below.
Sharing to a group email address:
Sharing to an entire domain:
Sharing at the domain level is only supported for G Suite domains, and only for the domain that the site is hosted at.For example http://sites.google.com/a/domain1.com/siteA can only share the entire Site with domain1.com, not domain2.com. Sites thatare not hosted on a G Suite domain (e.g. http://sites.google.com/site/siteB) cannot invite domains.
Modifying sharing permissions
To an existing sharing permission on a Site, first fetch the
AclEntry in question, modify the permissionas desired, and then call the client's Update() method to modify the ACL on the server.
This example modifies our previous
acl_entry from the Sharing a site section,by updating '[email protected]' to be a writer (collaborator):
For more information about ETags, see the Google Data APIs reference guide.
Removing sharing permissions
To remove a sharing permission, first retrieve the
AclEntry , then call the client's Delete() method.
You can also pass the
Delete() method the acl entry's edit link and/or force the deletion:
For more information about ETags, see the Google Data APIs reference guide.
Special TopicsRetrieving a feed or entry again
If you want to retrieve a feed or entry that you've retrieved before, you can improve efficiency by tellingthe server to send the list or entry only if it has changed since the last time you retrieved it.
To do this sort of conditional retrieval, pass in an ETag value to the
GetEntry() . For example, if you had an existing entry object:
If
GetEntry() throws the gdata.client.NotModified exception, the entry'sETag matches the version on the server, meaning you have the most up-to-date copy.However, if another client/user has made modifications, the new entry will be returned in entry and no exception will be thrown.
For more information about ETags, see the Google Data APIs reference guide.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |