How to check if a user is registered in their google account via API?

I am developing a page to view a preview of the documents available to the user.

For preview I use iframe with src = https://docs.google.com/viewer?authuser=0&srcid= {document id}

The problem is that when the user does not register, he shows an empty iframe.

I want to redirect the user to the google login page if the current user is not logged in and then displays the page while viewing the document.

For this feature, I will first need to check if the user is registered with Google or not.

I think google has some limitations imposed in the case of an iframe so that it does not redirect to the login page.

How can I implement it through the API?

+3
source share
1 answer

If you are using App Engine, do the following:

To view the page on which the google document is displayed, it must be checked if you are logged in.

Just configure the Google Users-API. Everything is described here:

https://developers.google.com/appengine/docs/java/users/overview

And set security restrictions in web.xml https://developers.google.com/appengine/docs/java/config/webxml#Security_and_Authentication

<security-constraint>
    <web-resource-collection>
        <url-pattern>/page_shows_google_doc</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>
0
source

All Articles