Signpost Oauth authentification on android application - android

I d like to use an Oauth authentification on my android application with a google account so that the user doesn't need to create a new login and password and that I don't have to handle the authentification but google does it in my place. I've been searching for a while but couldn't found informations on how to do this with a google account on an android app. Does anyone know about that ?

There's no need to use a special OAuth Library like signpost. Android has an AccountManager with Google OAuth support built in.
See this answer for a minimalistic example on how to use it. Google's account type is com.google.
Google has also has a step-by-step guide on how to implement this using the access_token then to call the Google Tasks API.

Related

Android - Google login with OAuth 2.0

In Android's sample app (that's provided with google play services) for google login, they are using this SCOPE - "oauth2:https://www.googleapis.com/auth/userinfo.profile"
and this end point - "https://www.googleapis.com/oauth2/v1/userinfo?access_token="
While I was implementing it I came across this document which (I think) states that this scope/endpoint is depricated:
Important: Google has deprecated the early implementation of OAuth 2.0 for login that is described in this document but will maintain it and keep it available for backward compatibility. If your app uses OAuth 2.0 login (early version), you might consider either switching to Google+ Sign-In or changing your existing userinfo endpoints and scopes as described in migration timetable. For instructions, see Migrate or update OAuth 2.0 login.
Since I don't want to limit my audience to Google+ users, I want to update the OAuth 2.0 login, but I don't know how to do that. I completely lost in google api documentations.
I saw this endpoint somewhere - https://www.googleapis.com/plus/v1/people/me
but don't know how to use it and if I should change the scope.. And I also didn't understand if it is a regular google login or google+ login (since it has the word "plus" in the path..).
I need an updated example/tutorial for google login.
Google+ Signin does use OAuth 2.0. I believe by OAuth 2.0 Login, you are referring to Open ID Connect. That link includes sample code as well as an strong overview on the whole OAuth flow.
Google+ Signin is still a perfectly valid option of authentication though. Signin works for any Google account, whether or not you use Google+ does not matter (unless you actually need Google+ user information). It's also, possibly, the easiest way to implement OAuth, as you can get away with just integrating the button (using the code provided) and it will suffice for most applications.

Login using Gmail credentials

Is there a way I can use Google credentials to get basic user info like
Email, Name, Gender
and use them in my application? Its like allowing user to login into my application using Gmail.
I asked the same here.
But the answer says:
You should not use Gmail for user authentication using Google
accounts. You can use Google + Sign-in for Android instead. This will
allow you to access the user's profile information upon getting the
required permissions using OAuth. Check out the guide here:
which i followed and everything worked fine.
But if a Gmail account has no GooglePlus profile, My application asks to create a GooglePlus account. Which makes me think I implemented a GooglePlus Login instead of Gmail Login.
Is the answer for my other question right? Meaning without a GooglePlus profile you cannot have a Gmail Login in Android?
If not how can I have a Google Login in my application?
A similar question here, with no replies.
Please help. Thank You
Try article on this Url : http://nilvec.com/implementing-smtp-or-imap-xoauth-authentication-in-java.html.
I think this will help you
I wouldn't confuse a "gmail" account and a "Google+" account as being different things. Really what you want is for a user to authenticate with their "Google account", which spans many services.
On Android, the easiest way to build authentication with Google accounts is to use the Google Play Services SDK, which includes services like Google sign in.
Google+ documents an end-to-end approach to using Google Play Services SDKs that cover the issues that you asked about by using the PlusClient:
Setting up the client
Getting the user's email address using either PlusClient.getAccountName() or the REST methods.
Getting the user's profile info using the PlusClient.loadPerson()
Documentation for using Google's OAuth2 to authenticate a user are provided at https://developers.google.com/accounts/docs/OAuth2Login. As the page notes, however, you and your users get additional features if they use a Google+ account and the Google+ Sign-in, but this is not necessary.
The scopes required are
https://www.googleapis.com/auth/userinfo.profile for name and gender
https://www.googleapis.com/auth/userinfo.email for the user's email address
Update: I should amend that these scopes are now deprecated, and scheduled for removal. See the URL above for details.

how to deal with Adsense API - Android

I want to make an App to read my earning on Adsense.
I made an app on Google and I generated a URL to login into the App.
https://accounts.google.com/o/oauth2/auth?from_login=0&response_type=code&scope=https://www.googleapis.com/auth/adsense&redirect_uri=xxxxxxxx&access_type=offline&as=-415b671ff3966dc2&pli=1&client_id=xxxxxxxxxxx&authuser=0&hl=en
but when the user login into the App and click on "Allow" the output has no access token just has "code".
also I want to know if there is an example of using google OAuth api on android because I tried to use it but I failed.
There's an AdSense Management API sample for Android in:
https://github.com/googleads/googleads-adsense-examples/tree/master/android
It uses Google Play Services to get the list of accounts on the device and the Google Client Library for Java to make the requests.
Yes, before calling any Google's API you need to be OAuth authenticated first, and thus to have a valid token.
Check this out to know how:
http://developer.android.com/training/id-auth/authenticate.html

Can I use AccountManager to let users sign in with their Google account?

I'm creating an app that will need users to create an account. (Like Facebook or Twitter would require you to.)
BUT, since it's an Android app, should/can I let them sign in with their Google Account using AccountManager or some other service? It'd be very helpful if they could just sign in to their Google account and their settings and other options would be saved to that account.
Main questions summed up:
Is it possible to let a user just use their Google account in my app?
If so, do I use AccountManager to have them sign in and save account information/settings?
What are other options?
Yes, you can get users to log into their Google Services using their Google credentials, for example, I have an app on Google Tasks and I use the Android AccountManager to let users authenticate themselves using their Google account on the android device (No need for users to enter their password!)
There are some really good examples to get you started:
This is an in-depth look into how you can authenticate based on the users Android credentials, has an example of how things work and how the UI should be: http://www.finalconcept.com.au/article/view/android-account-manager-step-by-step-2
This is an example of getting AccountManager to work with a Google service like Google Tasks: https://developers.google.com/google-apps/tasks/oauth-and-tasks-on-android
The last example is using the same concept for accessing the Google Picasa service: http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager
The other options you have is to have users manually enter their username/password. For that you have to use a third party authentication API (like signpost for OAuth) for them to log in.
In my tasks/todo application I provide users both options to sign in, using their android credentials or using third party authentication for users that want to log in using some other account (an account which is not enabled on that device)
Let me know if you have more questions
Although it is a new development, Google Plus Sign-in introduced as part of Google Play Services can also be used. More info can be found at Android developers blog. See example implementation from Banjo app
There seems to be a big limitation - The user need to have Google+ app installed on the device to use this.
Also this is a pretty good blog if someone is interested in implementing the solution.
#Soham gave you some very useful links but he didn't correct one major error: AccountManager is the entity that manages the accounts on your Android device - it has nothing to do with your google account! you can use google account and create a NEW account on your device using the AccountManager.
The rest you can learn from the links Soham gave you.

Authentication on Android Apps?

I have been building an application on android and wanted to do some user authentication using twitter oAuth. But is there any service by google which will allow user authentication easily? Could you please let me know if any other services exist for android ?
Regards,
Lalith
I haven't tried it but I believe you can use openid authentication which accepts google login too. Details about openid with google is here:
http://code.google.com/apis/accounts/docs/OpenID.html

Categories

Resources