403 on insert new post via python api
Andrey Averkiev <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <[email protected]> |
"""A simple example of how to access the Google Analytics API."""
import argparse
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools
def get_service(api_name, api_version, scope, key_file_location,
service_account_email):
"""Get a service that communicates to a Google API.
Args:
api_name: The name of the api to connect to.
api_version: The api version to connect to.
scope: A list auth scopes to authorize for the application.
key_file_location: The path to a valid service account p12 key file.
service_account_email: The service account email address.
Returns:
A service that is connected to the specified API.
"""
credentials = ServiceAccountCredentials.from_p12_keyfile(
service_account_email, key_file_location, scopes=scope)
http = credentials.authorize(httplib2.Http())
# Build the service object.
service = build(api_name, api_version, http=http)
return service
def main():
# Define the auth scopes to request.
scope = ['https://www.googleapis.com/auth/blogger']
# Use the developer console and replace the values with your
# service account email and relative location of your key file.
service_account_email = ''
key_file_location = ''
# Authenticate and construct service.
service = get_service('blogger', 'v3', scope, key_file_location,
service_account_email)
response = service.posts().get(blogId='', postId='').execute()
p = response
response = service.posts().insert(blogId='',body=p).execute()
print(response)
# profile = get_first_profile_id(service)
# print_results(get_results(service, profile))
if __name__ == '__main__':
main()
I thought that problem is in format of body, but even if I try to get
content from one post and create new one with the same content - I getting
"returned "We're sorry, but you don't have permission to access this
resource."
--
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.