Sep-09-2019, 05:02 AM
I have been trying to find a way to automate blogger Post, i was able to access normal data of my blog with a API Key, For Posting I need to have a OAuth v2 authorization I didnt find any good tutorial/sample code for this.
i found this page which is quite similar to what to do but it require a manual copy/paste of authorize code
http://www.datadependence.com/2016/03/go...ry-oauth2/
i found this page which is quite similar to what to do but it require a manual copy/paste of authorize code
http://www.datadependence.com/2016/03/go...ry-oauth2/
import requests
from apiclient.discovery import build
import oauth2client
from oauth2client import file
import apiclient.discovery
import webbrowser
import httplib2
Key = "hidden"
BlogId = "hidden"
Scope = "https://www.googleapis.com/auth/blogger"
blog = build('blogger','v3', developerKey=Key)
def get_credentials():
"""Gets google api credentials, or generates new credentials
if they don't exist or are invalid."""
flow = oauth2client.client.flow_from_clientsecrets(
'client.json', Scope,
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
storage = oauth2client.file.Storage('credentials.dat')
credentials = storage.get()
if not credentials or credentials.invalid:
auth_uri = flow.step1_get_authorize_url()
webbrowser.open(auth_uri)
auth_code = input('Enter the auth code: ')
credentials = flow.step2_exchange(auth_code)
storage.put(credentials)
return credentials
def get_service():
"""Returns an authorised blogger api service."""
credentials = self.get_credentials()
http = httplib2.Http()
http = credentials.authorize(http)
service = apiclient.discovery.build('blogger', 'v3', http=http)
return servicedoes anyone know any resource/tutorial to Oauth v2, Google api and python intergration for automate the blog posting.....??
