Hi,
I'm starting with this API and I'm trying to update a given group setting
in Java.
I'm using the source code which is in
google-api-services-groupssettings-v1-1.3.0-beta.jar.
Unfortunately I'm getting a 401 Unauthorized error when I run my app.
I'm maybe doing something wrong. I'm not able to solve this issue.
If someone has the answer it would be very helpful.
Thanks in advance.
Regards
Rob
You can find below the error message:
*Exception in thread "main"
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401
Unauthorized
at
com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:138)
at
com.google.api.client.googleapis.services.GoogleClient.execute(GoogleClient.java:123)
at
com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:67)
at
com.google.api.services.groupssettings.Groupssettings$Groups$Update.execute(Groupssettings.java:614)
at com.ipsen.test.main(test.java:107)
*
You can find the java code below:
*
public static void main(String[] args) throws IOException {
String authorizeUrl = new
GoogleAuthorizationRequestUrl(CLIENT_ID,
CALLBACK_URL, SCOPE).build();
System.out.println("Paste this url in your browser:
" + 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
GoogleAuthorizationCodeGrant authRequest = new
GoogleAuthorizationCodeGrant(TRANSPORT,
JSON_FACTORY, CLIENT_ID, CLIENT_SECRET,
authorizationCode, CALLBACK_URL);
authRequest.useBasicAuthorization = false;
AccessTokenResponse authResponse =
authRequest.execute();
String accessToken = authResponse.accessToken;
GoogleAccessProtectedResource access = new
GoogleAccessProtectedResource(accessToken,
TRANSPORT, JSON_FACTORY, CLIENT_ID,
CLIENT_SECRET, authResponse.refreshToken);
HttpRequestFactory rf =
TRANSPORT.createRequestFactory(access);
System.out.println("Access token: " +
authResponse.accessToken);
// Make an authenticated request
Groups groups = new Groups();
groups.setWhoCanPostMessage("ANYONE_CAN_POST");
Groupssettings settings = new
Groupssettings(TRANSPORT,JSON_FACTORY);
settings.builder(TRANSPORT, JSON_FACTORY);
Groupssettings.Groups.Update update =
settings.groups().update(groupemail,groups);
groups = update.execute();
}
*
--
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/-/U5nJ3LuHbXkJ.
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.