Google API and Oauth2
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Google API and Oauth2
I would like to use google's API to connect a LiveCode app to a blogger account. Basically I have a couple thousand articles that need to be posted to a blogger page. The app would go through a folder of TXT files and parse them into title and content sections, then use the blogger API blogger.posts.insert to post them to a blog. I am certain LiveCode can do it, but I am a little lost on how to connect my application to the account using the Oath2 ClientID and secret. My google-fu is coming up short, so if anyone could point me in the direction of a good tutorial,library, or anything really,it would be much appreciated!
Thanks in advance,
--Sefro
Thanks in advance,
--Sefro
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Google API and Oauth2
A little more info:
I am able to get an authorization token by launching a URL that looks something like this:
Then I set the httpheaders to this:
finally i try to urlencode the JSON and POST it to the API:
When I try to post, it throws an error 411 Length Required...... Any hints? I am trying to use the guide from here:
https://developers.google.com/blogger/d ... ddingAPost to get this working. I would love any ideas on how to get this to work.....
--sefro
I am able to get an authorization token by launching a URL that looks something like this:
Code: Select all
https://accounts.google.com/o/oauth2/auth?redirect_uri="&tRedirect_URI&"&response_type=code&client_id=" \
&tClientID&"&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2F"&tscope&"&approval_prompt=force&access_type=online
Code: Select all
POST https://www.googleapis.com/blogger/v3/blogs/[myBlogID)/posts/
Authorization: [The authorization Token I just recieved]
Content-Type: application/json
finally i try to urlencode the JSON and POST it to the API:
Code: Select all
{
"kind": "blogger#post",
"blog": {
"id": "[myBlogID]"
},
"title": "This is a Test Article",
"content": "This is the content of my Article!"
}
https://developers.google.com/blogger/d ... ddingAPost to get this working. I would love any ideas on how to get this to work.....
--sefro
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Google API and Oauth2
A glimmer of hope from an old link:
http://runtime-revolution.278305.n4.nab ... 45121.html
But upon further googling I can't find anything about lib.aag.google, so I'm not sure if it ever happened....
I really not sure what to try.... Anybody?
http://runtime-revolution.278305.n4.nab ... 45121.html
But upon further googling I can't find anything about lib.aag.google, so I'm not sure if it ever happened....
I really not sure what to try.... Anybody?
Re: Google API and Oauth2
Hi Sefro,
Not sure how much this will help but I think it's asking for "Content-Length:" like "Content-Type: application/json"
Check out this script from Jacque for use:
Simon
Not sure how much this will help but I think it's asking for "Content-Length:" like "Content-Type: application/json"
Check out this script from Jacque for use:
Code: Select all
on startup
put "tipTemplate.txt" into theTemplateFile
if there is not a file theTemplateFile then
put "Error: template missing" into theData
else
put url ("file:"&theTemplateFile) into theData
put offset("[*]",theData) into theStartChar
put getTip() into char theStartChar to theStartChar+2 of theData
end if
# write minimal set of HTTP headers to stdout
put "Content-Type: text/html" & cr
put "Content-Length:" && the length of theData & cr & cr --"length" is a liveCode function
put theData
end startup
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Google API and Oauth2
Thanks Simon,
I changed my header to look like this:
POST https://www.googleapis.com/blogger/v3/blogs/[myBlogID)/posts/
Authorization: [The authorization Token I just recieved]
Content-Type: application/json
Content-Length: 162
162 is the length of the sample JSON I am trying to post, still getting an error 411. It is quite possible that I am missing something, but not sure what.......
I changed my header to look like this:
POST https://www.googleapis.com/blogger/v3/blogs/[myBlogID)/posts/
Authorization: [The authorization Token I just recieved]
Content-Type: application/json
Content-Length: 162
162 is the length of the sample JSON I am trying to post, still getting an error 411. It is quite possible that I am missing something, but not sure what.......
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Google API and Oauth2
I still haven't figured this one out. This is the script that I am trying to use to post:
Does anybody see anything I am missing here?
--Sefro
Code: Select all
on mouseup
put fld "blogID" into tBlogID
put field "token" into tToken
put field "Title" into tTitle
put field "body" into tBody
set the httpHeaders to \
"Authorization:"&&tToken & cr & \
"Content-Type: application/json"
put "{""e&"kind""e&":"&"e & "blogger#post" "e& ","\
"e&"blog""e&":"& "{" "e &"id"& quote & ":" "e &tBlogID"e&"},"\
"e&"title""e&":""e& tTitle"e&","\
"e&"content"& quote & ":" & quote &tBody& quote&"}" into tPost
put "https://www.googleapis.com/blogger/v3/blogs/"&tBlogID&"/posts/" into tBlogURL
post tPost to url tBlogURL
answer the result
answer tblogURL
end mouseup
--Sefro