google-apps interview questions
Top google-apps frequently asked interview questions
I am using Google Apps API for my application and trying to authorize it using OAuth2. I have created a project and an application within it using the Google API console. I am using the following URL for authorization:
https://accounts.google.com/o/oauth2/auth&scope=https://www.googleapis.com/auth/admin.directory.user&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=(my application clientid)
I get the following error,
Error: invalid_client
no application name
Request Details
I have verified the clientid and even the status of admin SDK.
Source: (StackOverflow)
I am working on Google API like chat, contacts and so on...
I am stuck on developer_key
as mentioned in gdata doc.
You can get this at https://code.google.com/apis/console:
'developer_key' => ''
I have already:
// OAuth2 Settings, you can get these keys at https://code.google.com/apis/console
'oauth2_client_id' => '',
'oauth2_client_secret' => '',
'oauth2_redirect_uri' => ''
Where can I find developer key?
I found some thing like this
http://code.google.com/apis/youtube/dashboard/gwt/index.html
But I understand this to be only for youtube.
Source: (StackOverflow)
I'm using google spreadsheets to prototype a bunch of numerical data for something I'm doing. Is there a way to essentially export a subset to a text file? Effectively, what I'm aiming to do is export a file I can include directly in the build for another project.
So is there a way to generate a text file for download?
Source: (StackOverflow)
Now that Google Apps will no longer have a free account, will we need to pay Google to be able to use custom domains on Google App Engine?
Source: (StackOverflow)
Do any of you use the javascript macro capabilities of Google Apps, particularly for spreadsheets? How do the capabilities compare? Is there anything that Google Apps can't do that can be done with VBA macros?
Source: (StackOverflow)
When trying to update an entry on Google Apps No ETag found
is returned.. Adding entries works just fine, but can't neither update or delete entries!?
The ETag is added to the header in one of the last lines in the code:
$this->gdata->updateEntry($doc->saveXML(), $update_entry->getEditLink()->href, null, array('If-Match' => '*'));
Exception
Expected response code 200, got 409
Code
private function update_entry($data, $update_entry=null){
$doc = new DOMDocument();
$doc->formatOutput = true;
$entry = $doc->createElement('atom:entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
$doc->appendChild($entry);
if($update_entry){
preg_match('/^"?([^"]*)"?$/i', $update_entry->getEtag(), $matches);
$etag_value = $matches[1];
$entry->setAttribute('gd:etag', $etag_value);
$id = $doc->createElement('id', 'http://www.google.com/m8/feeds/contacts/'.$this->admin_user.'/base/'.$data['alias']);
$entry->appendChild($id);
}
$name = $doc->createElement('gd:name');
$entry->appendChild($name);
$fullName = $doc->createElement('gd:fullName', $data['name']);
$name->appendChild($fullName);
if($data['title']){
$org = $doc->createElement('gd:organization');
$org->setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
$entry->appendChild($org);
$orgName = $doc->createElement('gd:orgTitle', $data['title']);
$org->appendChild($orgName);
}
if($data['email']){
$email = $doc->createElement('gd:email');
$email->setAttribute('address', $data['email']);
$email->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
$entry->appendChild($email);
}
if($data['phone_work']){
$phone_work = $doc->createElement('gd:phoneNumber', $data['phone_work']);
$phone_work->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
$entry->appendChild($phone_work);
}
if($data['phone_work_mobile']){
$phone_work_mobile = $doc->createElement('gd:phoneNumber', $data['phone_work_mobile']);
$phone_work_mobile->setAttribute('rel', 'http://schemas.google.com/g/2005#work_mobile');
$entry->appendChild($phone_work_mobile);
}
if($update_entry){
echo $doc->saveXML();
$this->gdata->updateEntry($doc->saveXML(), $update_entry->getEditLink()->href, null, array('If-Match' => $etag_value));
}
else{
$this->gdata->insertEntry($doc->saveXML(), 'http://www.google.com/m8/feeds/contacts/'.self::DOMAIN.'/full');
}
}
XML
<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="CxFbERtcFit7I2Bu">
<id>http://www.google.com/m8/feeds/contacts/admin_user@domain.com/base/alias</id>
<gd:name>
<gd:fullName>name</gd:fullName>
</gd:name>
<gd:organization rel="http://schemas.google.com/g/2005#work">
<gd:orgTitle>title</gd:orgTitle>
</gd:organization>
<gd:email address="mail@domain.com" rel="http://schemas.google.com/g/2005#work"/>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work">22260435</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work_mobile">1112223</gd:phoneNumber>
</atom:entry>
Source: (StackOverflow)
I uploaded a file to Google spreadsheets (to make a publically accessible example IPython Notebook, with data) I was using the file in it's native form could be read into a Pandas Dataframe. So now I use the following code to read the spreadsheet, works fine but just comes in as string,, and I'm not having any luck trying to get it back into a dataframe (you can get the data)
import requests
r = requests.get('https://docs.google.com/spreadsheet/ccc?key=0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc&output=csv')
data = r.content
The data ends up looking like: (1st row headers)
',City,region,Res_Comm,mkt_type,Quradate,National_exp,Alabama_exp,Sales_exp,Inventory_exp,Price_exp,Credit_exp\n0,Dothan,South_Central-Montgomery-Auburn-Wiregrass-Dothan,Residential,Rural,1/15/2010,2,2,3,2,3,3\n10,Foley,South_Mobile-Baldwin,Residential,Suburban_Urban,1/15/2010,4,4,4,4,4,3\n12,Birmingham,North_Central-Birmingham-Tuscaloosa-Anniston,Commercial,Suburban_Urban,1/15/2010,2,2,3,2,2,3\n
The native pandas code that brings in the disk resident file looks like:
df = pd.io.parsers.read_csv('/home/tom/Dropbox/Projects/annonallanswerswithmaster1012013.csv',index_col=0,parse_dates=['Quradate'])
A "clean" solution would be helpful to many to provide an easy way to share datasets for Pandas use! I tried a bunch of alternative with no success and I'm pretty sure I'm missing something obvious again.
Just a Update note The new Google spreadsheet has a different URL pattern Just use this in place of the URL in the above example and or the below answer and you should be fine here is an example:
https://docs.google.com/spreadsheets/d/177_dFZ0i-duGxLiyg6tnwNDKruAYE-_Dd8vAQziipJQ/export?format=csv&id
see solution below from @Max Ghenis which just used pd.read_csv, no need for StringIO or requests...
Source: (StackOverflow)
I have a private website used as an intranet site for workers from around the world who have accounts with my Google Apps domain (example.com). They currently use OpenId to log in to various collaborative tools, so I want to use this for my site too.
I want to protect the static content on my private members-only website with OpenID login (rather than, say, basicc HTTP auth), which Google Apps provides.
I know that anyone can be an OpenID provider, so I want to restrict it to one domain name - specifically my Google Apps domain.
At the moment my static content is served via nginx. I would prefer a simple nginx module that would handle this with only a bit of setup.
If I have to get my hands dirty, I don't mind setting up a basic Python (say Django) or Java server to handle this, but I don't want to use PHP or Ruby.
Source: (StackOverflow)
I am trying to use Bill the Lizard's code to send an email using Google Apps. I am getting this error:
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. f3sm9277120nfh.74
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:81)
at SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:44)
Bill's code contains the next line, which seems related to the error:
props.put("mail.smtp.starttls.enable","true");
However, it does not help.
These are my import statements:
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
Does anyone know about this error?
Source: (StackOverflow)
Does anyone know if it is going to be possible anytime soon to setup SSL for a custom domain without a Google App account directly from the Google cloud developers console? Signing up for yet another Google account is bordering on making me insane.
I have setup a custom domain via the Google cloud developers console for my app project, and this is serving as a naked url...no problem.
Then I tried to setup a Google App account with an existing account linked to my Google App Engine project as an owner, but it didn't like it. So I setup a new one (deleted now) and re-verified the custom domain, which then stopped the serving of the custom domain. I then deleted the Google App account and it started serving the custom domain again. I have no idea why, what or how...
I have purchased an SSL certificate from Comodo, not yet activated, and all I want to do is set it up without giving myself an emotional hernia, I get enough of those from coding! And, yes, read the docs, but you know, they suck! A step by step idiots example would be great!
Does anyone have a guide other than a google doc on how to setup SSL for a custom domain including activating the SSL cert etc. etc.
Thanks one and all
Source: (StackOverflow)
Is it possible to achieve SSO with the built-in OpenId on App Engine? I've been trying to integrate a Marketplace app and get the user logged in when coming from Google Apps (the admin panel or universal navigation). I failed miserably, then now I found this:
"The one exception to this is applications which do hybrid OpenID/OAuth — whitelisting does not currently work with this approach." (from here)
I assume that I have to implement OpenId using a library instead of using the built-in one to achieve SSO with Google Apps in my app? Or if it is possible with built-in OpenId, is there an example anywhere that shows how to do this?
Source: (StackOverflow)
I've been using the great GoogleAppsAuthentification extension for mediawiki to allow my users to log in with their Google Apps account. We recently added another domain to our Google Apps and I'd like to offer those users the option to log into our wiki with their Google Apps Domain.
Out of the box, this isn't possible with the extension, however it seems pretty trivial to add multiple domain support.
The idea is to prompt the user with a dropdown list of available domains prior to executing the redirect to Google's login screen.
My knowledge of the mediawiki API is rather limited and I could use some pointers.
the extension hooks into the UserLoadFromSession hook, which is called before the UserLoginForm hook. I would have to add code to this function to prompt the user for a domain, and return to this function, passing the selected domain to getGoogleAccount()
// in LocalSettings.py
$wgDefaultUserOptions['GoogleAppsDomainList'] = array("domain.com", "otherdomain.com");
// in GoogleAppsAuthentication.php
function fnGoogleAppsAuthenticateHook($user, &$result){
global $IP, $wgLanguageCode, $wgRequest, $wgOut, $wgDefaultUserOptions;
if (isset($_REQUEST["title"])){
$lg = Language::factory($wgLanguageCode);
if ($_REQUEST["title"] == $lg->specialPage("Userlogin")){
// this is where we need to add the prompt
// that asks the user which domain to chose
$domain = getDomainFromUser($wgDefaultUserOptions['GoogleAppsDomainList'])
// Setup for a web request
require_once("$IP/includes/WebStart.php");
// Here we do our stuff
$googleAccount = getGoogleAccount('title=' . $_REQUEST["title"], $domain);
// whole bunch of code here that won't be affected by our change
...
// end whole bunch of code that won't be affected by our change
} else if ($_REQUEST["title"] == $lg->specialPage("Userlogout")) {
session_unset();
// Logout
$user->logout();
}
}
// Back to MediaWiki home after login
return true;
}
function getDomainFromUser($domainList) {
// render page with dropdown containing domains in $domainList
// get selected dropdown on page submit
// return selected domain
}
I need some help with the getDomainFromUser() function. I don't know how to redirect to a new page that shows a dropdown menu populated by an array defined in the LocalSettings.py and return the selected value back to the fnGoogleAppsAuthenticateHook function.
Any help would be sincerely appreciated. I believe a lot more people can benefit from this additional functionality added to this extension.
Source: (StackOverflow)
I'm beginning to seriously doubt the OpenID community despite that fact that it works.
I'm in the process of currently evaluating OpenID as an authentication service for 'this' site and while the promises are great, I just can't get it to work. And I'm really lost.
I ask of the SO community to help me out here. Give me answers and show me examples so I can leverage this in the way it was meant to be.
My scenario is very typical. I want to authenticate users through a specific Google Apps domain. If you have access to this Google Apps domain, then you have access to my web application.
Where I get lost, is all the prerequisites and dependencies involved.
- What is XRD?
- What is Yadis?
- Why do I need XRD and Yadis?
- What do I need to do to deploy OpenID authentication on my website?
Also, this is really important to me.
When I login to SO, I use my Google Account. When I click the login button I'm presented with this confirmation page. Where I'm granting SO the right to use my Google Account credentials.
Somehow, Google knows that it's "Stackoverflow.com" that's asking me if it's okay to login. And I wish to know what manner of control I have over this little text. I intend to deploy OpenID on several different domains but I would prefer if they would all work without having to be individually configured with special parameters, such as secret API keys and what not. However, I don't know for sure if this is a prerequisite of OpenID, that or the Federated Login API that Google provides.
Source: (StackOverflow)
We created an application for Google Apps Marketplace. Our app works only if it's installed for everyone. But the problem is, some customers install our app for some organizations, not everyone. We want to display a specific message to those customers, but the problem is that we don't know if our app is installed for some organizations, or not installed at all. Therefore, customers who installed our app for some organizations get a message which is intended for customers who didn't install our app at all. We show them the install button but nothing happens when they install our app again, because it's already installed. We want to give them instructions how to change our app's status to "on for everyone".
How can we check if our app is installed for some organizations? We get the following error message from Google:
Failed to retrieve access token: {
"error" : "unauthorized_client",
"error_description" : "Unauthorized client or scope in request."
}
Which is the same error message we receive for cutomers who didn't install our app at all.
This is the Python function who throws the exception:
def _do_refresh_request(self, http_request):
"""Refresh the access_token using the refresh_token.
Args:
http_request: callable, a callable that matches the method signature of
httplib2.Http.request, used to make the refresh request.
Raises:
AccessTokenRefreshError: When the refresh fails.
"""
body = self._generate_refresh_request_body()
headers = self._generate_refresh_request_headers()
logger.info('Refreshing access_token')
resp, content = http_request(
self.token_uri, method='POST', body=body, headers=headers)
if resp.status == 200:
# TODO(jcgregorio) Raise an error if loads fails?
d = simplejson.loads(content)
self.token_response = d
self.access_token = d['access_token']
self.refresh_token = d.get('refresh_token', self.refresh_token)
if 'expires_in' in d:
self.token_expiry = datetime.timedelta(
seconds=int(d['expires_in'])) + datetime.datetime.utcnow()
else:
self.token_expiry = None
if self.store:
self.store.locked_put(self)
else:
# An {'error':...} response body means the token is expired or revoked,
# so we flag the credentials as such.
logger.info('Failed to retrieve access token: %s' % content)
error_msg = 'Invalid response %s.' % resp['status']
try:
d = simplejson.loads(content)
if 'error' in d:
error_msg = d['error']
self.invalid = True
if self.store:
self.store.locked_put(self)
except StandardError:
pass
raise AccessTokenRefreshError(error_msg)
Update 1: in Apps > Marketplace apps, an app can be on for everyone, on for selected orgs or off. We need to know the status of our app.
Update 2: I tried calling check_general_access
but also when our application is uninstalled we receive True (Application has general access). This is after we confirmed that check_access
returned False.
@staticmethod
def check_access(admin_email):
http = httplib2.Http()
credentials = SignedJwtAssertionCredentials(
SERVICE_EMAIL,
PRIVATE_KEY,
scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/ https://www.googleapis.com/auth/admin.directory.user.readonly',
sub=str(admin_email),
)
http = credentials.authorize(http)
try:
service = build(serviceName='admin', version='directory_v1', http=http)
logging.info("Application has access to admin's %s domain" % (admin_email))
return True
except Exception as e:
logging.info("Application does not have access to admin's %s domain (exception: %s)" % (admin_email, e.message))
return False
@staticmethod
def check_general_access():
http = httplib2.Http()
credentials = SignedJwtAssertionCredentials(
SERVICE_EMAIL,
PRIVATE_KEY,
scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/ https://www.googleapis.com/auth/admin.directory.user.readonly',
)
http = credentials.authorize(http)
try:
service = build(serviceName='admin', version='directory_v1', http=http)
logging.info("Application has general access")
return True
except Exception as e:
logging.info("Application does not have general access (exception: %s)" % e.message)
return False
Source: (StackOverflow)