Julian,
Thanks for the code - it took a while to realize this goes into the
AppsForYourDomainClient.java code in the samples directory. I had
originally gotten both the Source and the Sample java provisioning zip
files and splattered them in the same directory, expecting Source to
go to the source area and Sample to go to the Sample area. This is
not the case for some parts of the two packages, as one will overlay
part of the other that they have in common. By only deploying the
Sample part of the provisioning JAVA samples, I have been able to
change the passwords for our users on Google in batch mode. I used a
two part approach with part one getting the token and part two using
the token. Part one will run every 24 hours to get a new token each
day. Part two will never care about the token age as part one will
furnish it for the actual password update process.
Another thing to note for others is the return of the token actually
has three lines as someone in another posting noted. To make this
work the third line needs to be used that begins with "Auth=". The
response from the Get Token looks like the following. I cut off some
of the data to fit the line:
SID=DQAAAIEAAABXkfLfHHuqat04dQT7gHifq-gcBR7mTDHUXN-mZZl_qNpRYA......
LSID=DQAAAIQAAAD_P6ZDUdeubfD7EmuS9ddMMDS4lIG0YiCokr9hUgkXrq5P.......
Auth=DQAAAIMAAAD_P6ZDUdeubfD7EmuS9ddMMDS4lIG0YiCokr9hUgkXrq5P.......
This process is for serving IMAP and POP users....
Thanks for your help!
- Terry Combs
On Aug 6, 4:38 am, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
> Hi Terry,
>
> The following code can be adapted into AppsForYourDomainClient to save
> and reuse Authetication Tokens:
>
> // Outsite the class on the imports section the following line:
> import
> com.google.gdata.client.appsforyourdomain.AppsForYourDomainService;
>
> // Within the class, some changes on the constructor, a new
> constructor and 2 methods for the token
> protected String authToken = null;
>
> public AppsForYourDomainClient(String adminEmail, String
> adminPassword,
> String domain) throws Exception {
>
> this.domain = domain;
> domainUrlBase = APPS_FEEDS_URL_BASE + domain + "/";
>
> userService = new UserService(
> "gdata-sample-AppsForYourDomain-UserService");
> userService.setUserCredentials(adminEmail, adminPassword);
>
> authToken = userService.getAuthToken(adminEmail, adminPassword,
> null,
> null, AppsForYourDomainService.APPS_SERVICE,
> "gdata-sample-AppsForYourDomain");
>
> initServices(authToken);
> }
>
> public AppsForYourDomainClient(String authToken,
>
> String domain) throws Exception {
>
> this.domain = domain;
> domainUrlBase = APPS_FEEDS_URL_BASE + domain + "/";
>
> initServices(authToken);
> }
>
> private void initServices(String authToken) {
> // Configure all of the different Provisioning services
> userService = new UserService(
> "gdata-sample-AppsForYourDomain-UserService");
> userService.setUserToken( authToken );
>
> nicknameService = new NicknameService(
> "gdata-sample-AppsForYourDomain-NicknameService");
> nicknameService.setUserToken( authToken );
>
> emailListService = new EmailListService(
> "gdata-sample-AppsForYourDomain-EmailListService");
> emailListService.setUserToken( authToken );
>
> emailListRecipientService = new EmailListRecipientService(
> "gdata-sample-AppsForYourDomain-EmailListRecipientService");
> emailListRecipientService.setUserToken( authToken );
> }
>
> public String getAuthToken() {
> return authToken;
> }
>
> public void setAuthToken( String authToken ) {
> this.authToken = authToken;
> }
>
> On Aug 4, 2:00 pm, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Yes, the code triggers a token retrieval, you need to modify the code
> > to cache/save the token and reuse it. Instead of 8 hours, is better to
> > retrieve the token closer to 24 hours, for example every 22-23 hours
> > to avoid CAPTCHA problems.
>
> > To retrieve the token you can use the class AppsForYourDomainService,
> > its super class GoogleService has token functions.
>
> > Julian.
>
> > On Aug 4, 1:35 pm, Terry C <[EMAIL PROTECTED]> wrote:
>
> > > Here is the code that is being used and which I assume triggers the
> > > token retrieval in the background in the Sample Provisioning setup for
> > > every iteration. Is access to the token available to this program
> > > after the initial signon so it can be retrieved and saved? We could
> > > then switch to using the token for subsequent use, or simply retrieve
> > > the token every 8 hours...
>
> > > - Terry Combs
>
> > > .
> > > .
> > > .
>
> > > String adminEmail = "[EMAIL PROTECTED]";
> > > String adminPassword = "adminpass";
> > > String domain = "email.domain";
>
> > > AppsForYourDomainClient appClient =
> > > new AppsForYourDomainClient(adminEmail, adminPassword,
> > > domain);
>
> > > On Aug 4, 6:10 am, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > You will get a CAPTCHA eventually if you authenticate too frequently and
> > > > do not reuse the token. To solve the problem you need to keep an
> > > > instance of the object alive as you say or cache the token. if you
> > > > chose to cache the token, it is recommended to store it in memory (not
> > > > the hard drive) for security reasons.
>
> > > > You can modify or add a new constructor to AppsForYourDomainClient,
> > > > that uses the token instead of password and email, for example:
>
> > > > public AppsForYourDomainClient(String token,
> > > > String domain) throws Exception {
>
> > > > this.domain = domain;
> > > > domainUrlBase = APPS_FEEDS_URL_BASE + domain + "/";
>
> > > > // Configure all of the different Provisioning services
> > > > userService = new UserService(
> > > > "gdata-sample-AppsForYourDomain-UserService");
> > > > userService.setUserToken( token );
>
> > > > nicknameService = new NicknameService(
> > > > "gdata-sample-AppsForYourDomain-NicknameService");
> > > > nicknameService.setUserToken( token );
>
> > > > emailListService = new EmailListService(
> > > > "gdata-sample-AppsForYourDomain-EmailListService");
> > > > emailListService.setUserToken( token );
>
> > > > emailListRecipientService = new EmailListRecipientService(
> > > > "gdata-sample-AppsForYourDomain-EmailListRecipientService");
> > > > emailListRecipientService.setUserToken( token );
> > > > }
>
> > > > Julian.
>
> > > > On Aug 1, 12:14 am, Terry C <[EMAIL PROTECTED]> wrote:
>
> > > > > I currently have a Java program which uses the sample provisioning jar
> > > > > files with some front end code developed locally. The program works
> > > > > fine in that the input is from a non-human source and kicks off a bash
> > > > > shell with something like:
>
> > > > > /usr/local/bin/gpasswdupd userperson userpassword
>
> > > > > The program updates one Google entry and terminates.
> > > > > When another password update is entered it will execute again.
>
> > > > > Will we eventually get CAPTCHA problems doing the update like this?
> > > > > Is there potentially a problem with the authorization token being
> > > > > requested from a batch type of program?
>
> > > > > Is there a better way to do this - maybe with some jsp file to handle
> > > > > input into a standby program that never closes?
>
> > > > > I don't want to implement a monster which we can't feed.
>
> > > > > Regards,
> > > > > Terry Combs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---