Re: problem with blogger java v3 api authentication

John Walton <[email protected]>
Newsgroups gmane.comp.web.blogger.api
Message-ID <[email protected]>
Brett, I assume you are posting on behalf of Google / Blogger?

If Blogger does not accept Service logins, then why:

1. Does "Blogger API: Using the API"

https://developers.google.com/blogger/docs/3.0/using

state:

"Service accounts

A service account is used in an application that calls APIs on behalf of an 
application that does not access user information. This type of application 
needs to prove its own identity, but it does not need a user to authorize 
requests. The *Google Accounts documentation* 
<https://developers.google.com/accounts/docs/OAuth2#serviceaccount> 
contains more details about service accounts.


2.  You have a "Help me choose" wizard in the Google Developers Console / 
Credentials. 

https://console.developers.google.com/apis/credentials/wizard?project=thermal-diorama-111315

If I select "Blogger API V3", from Web Server, Application data, no Google 
engine, it tells me I can use my existing "Service account 1" !!!

So are the above all lies?

Before V3 I had no problems posting entries to my blog (using my own 
blogger data). It now seems impossible, and all above information on Google 
web pages about the subject seems to be in error..

Please help - very simple requirement!

Previously posted, in more detail, on Jan 31, with no response.





On Tuesday, June 2, 2015 at 7:18:38 AM UTC+1, Brett Morgan wrote:

> We don't accept service account logins on Blogger, sorry.
>
> brett
>
> On Tue, Jun 2, 2015 at 4:12 PM Paul Foxson <[email protected] 
> <javascript:>> wrote:
>
>> Hi
>> I'm trying run a sample post insert using Blogger JAVA v3 api and running 
>> into issues.   Please let me know what I'm missing or doing incorrectly or 
>> my setup is incorrect.
>> Our applications runs periodically without any user interaction and 
>> automatically post to our blog.  Process runs on a stand alone machine 
>> without any user interaction. It was working fine before gdata was 
>> deprecated.   
>>
>> I took the following steps:
>> 1. enabled Blogger API v3 in developer console.   
>> 2. created a service account under credentials and downloaded .p12 file. 
>>   (I assume service accounts are supported since 
>> google-api-services-blogger-v3-rev48-java-1.20.0 has calls 
>> like setServiceAccountId, setServiceAccountScopes 
>> and setServiceAccountPrivateKeyFromP12File).
>> 3. downloaded google-api-services-blogger-v3-rev48-java-1.20.0
>>
>> Running code below and getting, this error:
>> 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."
>> }
>> at 
>> com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
>> at 
>> com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
>> at 
>> com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
>> at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
>> at 
>> com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
>> at testAuth.main(testAuth.java:136)
>>
>> -------------------------------------------
>> my code:
>> try {
>> HttpTransport httpTransport = 
>> GoogleNetHttpTransport.newTrustedTransport();
>> JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
>>
>> GoogleCredential credential = 
>> new GoogleCredential.Builder()
>>
>> .setTransport(httpTransport)
>>
>> .setJsonFactory(jsonFactory)
>>
>> .setServiceAccountId("[email protected] 
>> <javascript:>")
>>
>> .setServiceAccountScopes(Collections.singleton(BloggerScopes.BLOGGER))
>>
>> .setServiceAccountPrivateKeyFromP12File(new File("xxxxxxxxxxx.p12")) 
>>
>> .build();
>>
>>
>> Blogger blogger = new Blogger.Builder(httpTransport, jsonFactory, 
>> credential)
>> .setApplicationName("My Project")
>> .build();
>>
>> // Construct a post to insert
>> Post content = new Post();
>> content.setTitle("A test post");
>> content.setContent("With <code>HTML</code> content");
>>
>> String TEST_BLOG_ID = "xxxxxxxxxxx9897";
>>
>> Insert postsInsertAction = blogger.posts().insert(TEST_BLOG_ID, content);
>>
>> // Restrict the result content to just the data we need.
>>
>> postsInsertAction.setFields("author/displayName,content,published,title,url");
>>
>> // This step sends the request to the server.
>> Post post = postsInsertAction.execute();   //fails here
>>
>> // Now we can navigate the response.
>> System.out.println("Title: " + post.getTitle());
>> System.out.println("Author: " + post.getAuthor().getDisplayName());
>> System.out.println("Published: " + post.getPublished());
>> System.out.println("URL: " + post.getUrl());
>> System.out.println("Content: " + post.getContent());
>>
>> } catch (GeneralSecurityException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> } catch (IOException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/bloggerdev.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.