Hi Gunjan, I just want to tell you a huge thanks. Your sample works great. I also tested the API with others settings, and I can update the settings.
Just a question: Is it possible to use this API with a client Login authentication (not Oauth)? Thanks a lot for your help! Rob 2011/12/5 robert dupont <[email protected]> > Gunjan, > > Thanks a lot for your reactivity and your help. > I will test this sample tomorrow and I will let you know if everythings is > ok. > You are right, it's a little tricky compare to the others APIs. > Thanks a lot again. > > > Regards, > > > Rob > > 2011/12/5 Gunjan Sharma <[email protected]> > >> Hello Robert >> >> Authenticating to Groups Settings API is a little tricky. Here is a >> sample code doing the updation. >> >> >> // Get the Authorization URL >> >> String authorizeUrl = new GoogleAuthorizationRequestUrl(CLIENT_ID, >> CALLBACK_URL, SCOPE).build(); >> >> System.out.println("Paste this url in your browser:\n" + >> authorizeUrl); >> >> // Wait for the authorization code >> >> System.out.println("Type the code you received here: "); >> >> BufferedReader in = new BufferedReader(new InputStreamReader(System. >> in)); >> >> String authorizationCode = in.readLine(); >> >> // Exchange for an access and refresh token >> >> AccessTokenResponse authResponse = new GoogleAuthorizationCodeGrant( >> >> TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, >> authorizationCode, >> >> CALLBACK_URL).execute(); >> >> System.out.println("Access token: " + authResponse.accessToken); >> >> GoogleAccessProtectedResource accessProtectedResource = >> >> new GoogleAccessProtectedResource( >> >> authResponse.accessToken, TRANSPORT, JSON_FACTORY, CLIENT_ID, >> >> CLIENT_SECRET, authResponse.refreshToken); >> >> // Make an authenticated request >> >> Groupssettings settings = Groupssettings.builder(TRANSPORT, >> JSON_FACTORY) >> >> .setApplicationName("GoupsSettingsJavaSample") >> >> .setHttpRequestInitializer(accessProtectedResource) >> >> .build(); >> >> Get getRequest = settings.groups().get("Your Group"); >> >> getRequest.set("alt", "json"); >> >> Groups group = getRequest.execute(); >> >> System.out.println(group.getName()); >> >> >> >> group.setWhoCanPostMessage("ANYONE_CAN_POST"); >> >> Update updateRequest = settings.groups().update("Your Group", group); >> >> updateRequest.set("alt", "json"); >> >> group = updateRequest.execute(); >> >> There are few things to note here . You have to use Groupssettings >> builder function to build the client. You need to assign the >> accessProtectedResource to the client as it contains your access token. >> Other than that for update you cannot set a parameter in empty object and >> call update. You need to modify a retrieved Groups object update the >> required fields and call update. There are other ways to update where you >> don't can do it without retrieving the group first. Refer >> this<http://code.google.com/googleapps/domain/group_settings/v1/using_api.html#GA_group_update_settings>. >> I hope it helps. >> >> Let us know if there is any other issue. >> >> >> Thanks >> >> Gunjan Sharma >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Apps Domain Information and Management APIs" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/google-apps-mgmt-apis/-/2tlMO7J-f-cJ. >> >> 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-mgmt-apis?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management 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-mgmt-apis?hl=en.
