问题
I am quite a beginner and learn at the moment "how to use apis properly": I imported the .jar files from code.google.com/p/google-api-java-client and added them via "external jar files" to the build path in eclipse.
The code snippet from https://developers.google.com/blogger/docs/3.0/reference/posts/insert can't work standalone since OAuth2Native and BloggerScopes aren't recognized because one has to authenticate onself first. can someone help me with this, giving advice about how to authenticate oneself in the simplest possible way?
i already found this: https://code.google.com/p/google-api-java-client/wiki/OAuth2Draft10
回答1:
You can find Google's sample OAuth2Native
implementation here.
For the missing scope constant, just construct an array with the Blogger scope manually:
final static String[] Blogger = { "https://www.googleapis.com/auth/blogger" };
回答2:
As of September 2015, There is no way to preauthorize someone for Blogger so I believe the only way to access Blogger Api is to generate access token through Auth 2 Playground ( https://developers.google.com/oauthplayground/ ) and then using the token for API call.
来源:https://stackoverflow.com/questions/12286783/posting-to-blogger-with-google-api-java-client