Re: Is service account support in blogger api?
Li Ga <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <[email protected]> |
hi Brett,
Is the following same case? Thanks
*I want to insert a post to my blog by php in my server cron so there is no
any manual login. I have create Service Account and can get the post by
$data = $blogger->posts->get('*
*6284611449262742568', '4655425391398964038');However, insert post fail
with following error.$data = $blogger->posts->insert('*
*6284611449262742568', $mypost);Fatal error: Uncaught exception
'Google_Service_Exception' with message 'Error calling POST
https://www.googleapis.com/blogger/v3/blogs/6284611449262742568/posts
<https://www.googleapis.com/blogger/v3/blogs/6284611449262742568/posts>:
(403) We're sorry, but you don't have permission to access this resource.'
in /xx/lab/GoogleClientApi/src/*
*Google/Http/REST.php:110Stack trace:#0 /xx/lab/GoogleClientApi/src/**Google/Http/REST.php(62):
Google_Http_REST::**decodeHttpResponse(Object(*
*Google_Http_Request), Object(Google_Client))#1 [internal function]:
Google_Http_REST::doExecute(*
*Object(Google_Client), Object(Google_Http_Request))#2
/xx/lab/GoogleClientApi/src/*
*Google/Task/Runner.php(174): call_user_func_array(Array, Array)#3
/xx/lab/GoogleClientApi/src/*
*Google/Http/REST.php(46): Google_Task_Runner->run()#4
/xx/lab/GoogleClientApi/src/**Google/Client.php(563):
Google_Http_REST::execute(**Object(Goog in /xx/lab/GoogleClientApi/src/*
*Google/Http/REST.php on line 110How can I have the permission to
insert/modify post to my blog?*
Thanks.
gaga
Brett Morgan於 2013年10月22日星期二 UTC+8下午4時46分43秒寫道:
>
> Hi Jimmy,
>
> Sorry, service accounts are not currently supported.
> On Oct 22, 2013 7:45 PM, "Jimmy Stock" <[email protected] <javascript:>>
> wrote:
>
>> I am getting following with the code. I think blogger need to invite
>> [email protected] <javascript:> but how
>> [email protected] <javascript:> accept it using gmail?
>>
>> {
>> "code" : 403,
>> "errors" : [ {
>> "domain" : "global",
>> "message" : "Forbidden",
>> "reason" : "forbidden"
>> } ],
>> "message" : "Forbidden"
>> }
>>
>>
>>
>> GoogleCredential credential = new GoogleCredential.Builder()
>> .setTransport(HTTP_TRANSPORT)
>> .setJsonFactory(JSON_FACTORY)
>> .setServiceAccountId("[email protected] <javascript:>")
>> .setServiceAccountScopes(BloggerScopes.all())
>> .setServiceAccountPrivateKeyFromP12File(
>> new File("9ffcc4041e16c0-privatekey.p12"))
>> .build();
>> System.out.println(credential.getRefreshToken());//null
>>
>> // set up global Plus instance
>> Builder blog = new Blogger.Builder(HTTP_TRANSPORT,
>> JSON_FACTORY,credential);
>> blog.setApplicationName("Service
>> Account-bit60qa1hh08g8lhbl4h33vef4hdngvjs");
>> // blog.setApplicationName("Blogger-PostsInsert-Snippet/1.0");
>> Post content = new Post();
>> content.setTitle("A test post");
>> content.setContent("With <code>HTML</code> content");
>> Blogger blogger = blog.build();
>> Insert insert = blogger.posts().insert("6828107655361625046123", content);
>> insert.setIsDraft(false);
>> insert.setFields("author/displayName,content,published,title,url");
>>
>> Post post = insert.execute();
>>
>> --
>> 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/groups/opt_out.
>>
>
--
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 http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.