Re: Authorization problem when updating a page in Blogger with Java
Peter Keller <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <[email protected]> |
I am facing the same (or similar?) problem. However I get a 403 status code:
Exception in thread "main"
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403
Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "We're sorry, but you don't have permission to access this
resource.",
"reason" : "forbidden"
} ],
"message" : "We're sorry, but you don't have permission to access this
resource."
}
Java setup:
// CLIENT_SECRETS_JSON points to the JSON credential file containing the
private_key
InputStream credentialStream =
RunClient.class.getResourceAsStream(CLIENT_SECRETS_JSON);
Collection<String> scopes = Collections.singleton(BloggerScopes.BLOGGER);
GoogleCredential credential = GoogleCredential.fromStream(credentialStream,
HTTP_TRANSPORT, JSON_FACTORY)
.createScoped(scopes);
Blogger blogger = new Blogger.Builder(HTTP_TRANSPORT, JSON_FACTORY,
credential).setApplicationName(APPLICATION_NAME).build();
Posts posts = blogger.posts();
Author author = new Author();
author.setId(USER_ID);
Post post = new Post();
post.setContent("<h1>Hallo Post</h1>");
post.setAuthor(author);
post.setTitle("API Test Post");
Insert postInsert = posts.insert(BLOG_ID, post);
postInsert.setIsDraft(true);
Post insertedPost = postInsert.execute();
Did you solve your problem?
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.