I’ve not had much luck finding information about this and I’m hoping that someone can point me in the right direction.
I am building a GWT app hosted on App engine, to post a request to a remote server. Very simple. My form has a name field that I’d like to populate with the user’s first name and last name. All the users will be in our business’s google apps domain. I am successfully getting the user’s email address by using the UserService as follows:
public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
public LoginInfo login(String requestUri) {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
LoginInfo loginInfo = new LoginInfo();
if (user != null) {
loginInfo.setLoggedIn(true);
loginInfo.setEmailAddress(user.getEmail());
loginInfo.setNickname(user.getNickname());
} else {
loginInfo.setLoggedIn(false);
}
return loginInfo;
}
}
Now, I need to somehow get the user’s first name and last name potentially using the email address to look this up.
I’ve thought of the following ways:
– Can I use the google contacts API somehow? I don’t really want to look at an individual user’s contacts, I’d like to look at the business’s contacts which we are bringing in from Active Directory via Google Apps Direcory sync.
– Can I use Oauth to do this? I haven’t really been able to find good info on how to do this.
– Can I somehow get this from the Google Apps Engine UserService? (I think I’ve concluded that you can’t do this – is that correct?)
– (Updated to add) I’m also looking into the provisioning API…I’m thinking this might work but don’t want to overlook a better/easier way.
Any ideas, thoughts, or suggestions will be greatly appreciated.
You can use OAuth 2.0 authentication as this allows your app to access users profile which include name. Look at OAuth client lib which works on GAE.
You could also use
scribe-up, which uses OAuth to get profiles from various providers, including Google.OTOH, if you are only doing this for one (your own) domain, then you’d be better off with Google Service Accounts, which gives user-independent access to particular Google Apps account. This way you could access profiles and get users data.