Working with Googles API's in front end or backend? - spring

I just started to work with Google API's (Calendar and Gmail for now). I already got both examples working on both my Frontend (React) and my Backend (Java - Spring).
I have the following doubt, If I want to enable users to be able to send email's using the oficial API not javax.mail should that be done on the Backend or it can be done on Frontend? Since the official documentation only shows examples on Java and Python.
If the answer is on Backend how will users be able to authenticate via OAuth2 If they are "not supposed" to see server-side information.
Thanks

Ok for does looking for an answer. I found the following guide...
https://developers.google.com/identity/sign-in/web/server-side-flow#step_1_create_a_client_id_and_client_secret
Basically you can get a client-side one time access code which is send to server-side where it can get a long-live access_token in order to have offline access once correct authentication has happened.

Related

Gem to post message on google plus?

Is there any gem to post message on google plus from our rails application ?. I want to post a meesage on my google plus page whenever i logged in my application using google plus credentials. Please suggest me the gem name to do this. Thanks in advance.
EDIT
I have a app in goole plus. On behalf of my application users, my app should post messages.
I suggest to use gem 'google_plus'`
As Google plus having so many restrictions. Still I would Like to Share a link you can follow that..
How to share content from our site to google plus
For more reference:
https://developers.google.com/accounts/docs/OAuth2
https://developers.google.com/+/web/share/interactive#button_attr_calltoactionurl
I hope it will work fine...
Yes, there's a Ruby client library provided by Google which allows you consume their Google+ API
https://developers.google.com/api-client-library/ruby/apis/plus/v1
UPDATE
The URL above points to Ruby client library. The API you're looking for is moments.insert
https://developers.google.com/+/api/latest/moments/insert
There is an official Google API Client gem. However the Google+ API does not allow standard automated posting to a profile. The recommended approach to share posts is the share button or the interactive share API.
The automated posting that Google+ does support are:
App activities/moments are a way to make actions within your app visible to other users of your app. They do not appear in the Google+ posts stream.
Domains API can be used with Google Apps accounts to create posts that are limited to users within the company.
Pages API can be used to post to a page (not a profile) but is limited to approved partners.

Access to GMail mailbox content with google-api

Is there a way to access a Gmail Mailbox using the google-api? I'm trying to do this from command line using Java FWIW.
I already have code in place that achieves this via IMAP so that is not what I'm looking for.
You can access GMAIL IMAPS and SMTP using XOAUTH authentication, see here :
https://developers.google.com/gmail/xoauth2_protocol
It is not really the google-api-java-client, it is plain IMAP/SMTP but authentication is OAUTH2.
After going through the Google API once again and considering this question did not get an answer in the past 6 days, I guess it is safe to say there is no other way aside from IMAP/S.
NOTE:
This question was initiated because I was told by numerous people that a certain Google API was available and preferable for this purpose. It seems they were all informed by the same person who was not able to show me his source of information and agreed that according to the documentation IMAP indeed is the only API available as of now.

Google Campaigns tracking with Spring Web flow

I am using Spring Web Flow for one of my clients and by default the Post-Redirect-Get (PRG) configuration is switched on for the website. The client now wants to enable Google Campaigns to allow them to track the campaigns they launching. But, due to the PRG configuration, the information is lost during the redirect. We have already tried to switch-off the PRG configuration but it results in issues in other flow. Is there is any solution which has been suggested for Spring Web flow to track the Google Campaigns.
Thanks in advance.
P.S: We are currently using spring-webflow-2.0.9 and spring MVC 2.5.6
We have been able to solve the problem by doing a workaround.The steps are given below.
To add a check in the application filter to look for all the Google Campaigns related data like utm_source / utm_medium / utm_campaign.
Once found them in filter, then store it in Application Cookie, on the server side.
In the page where the tracking needs to be added, add the JavaScript to check if these Cookies have been set.
If the cookies are set then we called _setCampValue() method, using the Javascript mentioned in the link extga.js
This JS sets the __utmz cookie, which Google Analytic uses for identifying the campaigns.
Please find the link of blog from which we have taken the javascript to modify the __utmz cookie used by Google Campaigns.
Thanks.

Api and consumer flow

I am developing an API for a social network website. This API will basically get all the requests from the users (get friend list, post a status update etc) and reply back if necessary.
We will implement OAuth 2.0 protocol for authentication. Consumer (our php project) has API id and secret.
Basic scenario:
Client wants to log in
API Consumer (php web project) takes this request, directs user to API
User send his/her user credentials to the api, gets the token.
User comes back to our website, pass token to the consumer.
Consumer goes to the api server, gets the access token.
Now consumer (php project) has access to user's private information.
Since this is a social network website, we want app developers to be able to use our API in the future.
I am not experienced in API-design. Does that flow make sense? I guess the simplest authentication would be accessing user information through php project. But we don't want to access database in php code. We will use ajax in client side and send a request to the API. And I believe there should be a better solution, what would you suggest?
Sure, API design is basically point where you need to choose technology.
Either it can be PHP or .net or Java.
I would prefer either PHP or .Net as we get lot of flexibility in it.
API will return XML or Json depending upon the request.
There are lot of CMS in php which can be helped.
.net we have Service Stack to help you.
API's had to be fully independent from other world as well as within API method as well.
If you are able to achieve this, then you will surely create a good architecture.

how to interpret google api oauth callback

i'm attempting to gain access to my own gmail account via a sinatra app i'm building. i'm sending a request to the google api in the form of
https://accounts.google.com/o/oauth2/auth?response_type=code&&scope=https://mail.google.com/+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&client_id=XXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=http://localhost:9393/oauth2callback&access_type=online
and after I authorize the app via google's web interface, i'm getting what appears to be a correct callback to my own sinatra app. I'm unclear what I do next in this process. what i'm getting from the google auth system looks like
http://localhost:9393/oauth2callback?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
I'm then attempting to use the xoauth gem to then query google for information about my account, ie, https://github.com/nfo/gmail_xoauth
My hope is that the xxxxxx.yyyy string above corresponds in some way to value of
:token as written in the xoauth gem documentation. when I run a local script to check if things are working correctly, i'm getting a Invalid credentials (Failure) (Net::IMAP::NoResponseError)
the documentation i'm using to understand the oauth process is https://developers.google.com/accounts/docs/OAuth2WebServer
i don't think i'm handling the callback correctly or either i'm misinterpreting what it is.
Thoughts?
Google has only added support for OAuth 2 authorization for GMail IMAP/SMTP recently. The library you are using however does not support this yet.
So your options are:
Improving the library yourself (would be my recommendation)
Waiting for the library to update
Falling back to the already deprecated OAuth 1

Resources