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
Related
Currently, i am able to add single account using Google Plus Api provided by Google in Android App.
Q: I want to support multiple google Account, get back multiple access token for all the accounts ? App need is that it has to be implemented using Google Api provided by Android. Implementing using Web-view is not recommended.
Solution Tried: disconnecting current and getting the new Account, but unfortunately it revoke the access of old Account.
Please guide me a way, thanks in advance..
Is there a way of implementing Google signin that does not require Google Play Services? I'm aware that the official docs says that you need GPS:
• https://developers.google.com/identity/sign-in/android/start-integrating
however I also found conflicting information here:
• Google Plus Login without Google Play Services
that says that using Google+ Api you can implement the login without the user having GPS. Which is true? Can you technically implement login without GPS or not? If you can it would be nice to use as a fallback for users who can't download GPS for whatever reason.
You can use the Android Account Manager to get an access token (if the user has signed in with his/her Google Account on the phone):
https://developers.google.com/android/guides/http-auth
If that is not what you want, you can always sign a user in using pure OAuth2 through a WebView. Here are some resources to get you started:
http://blog.doityourselfandroid.com/2011/08/06/oauth-2-0-flow-android/
How do you obtain a oAuth2 token using webView in android?
android OAuth-2.0 google login for user info using webview
If you choose to use a webview you will have to handle access/refresh tokens manually, which might or might not be convenient for you.
Good Luck!
Edit: You mentioned G+ in your post, so here is some information on how to add G+ scopes to your request:
https://developers.google.com/+/web/api/rest/oauth
(Choose a scope that you need and include it in your request for access/refresh token)
I'm writing an app that requires a user sign in with Google on Android and then proceeds to get data from the server (a Google App Engine instance, in this case). How could I go about making sure that the user is actually logged in instead of just calling with a user ID? Is there a way for google to check a secure token they provide on Android for authenticity? Or is there another non-google related way to do this?
Thank you for the help!
Okay, so this is actually a very simple task. You ask Google Play Services for its OAuth Token and send that. Then the server asks Google about that token and Google will give it all of the information in the scope at once using one of their multiple limitless OAuth APIs.
I'd like to use SSO (Single Sign-On) for users of my app, but I don't understand how to apply it to my case.
To summarize, we have:
a database
a website
an iPhone app / an Android App
Currently, it's possible to create an account on the site, and then use the same credentials to connect from the mobile apps. All communications between mobile apps and server work through http requests.
To put it simply, I would firstly
be able to use Google accounts to authenticate users
offering Android users to choose one of Google accounts associated with their smartphone
I found several sources of information:
Google - Using OAuth 2.0 for Login
Android - Remembering Users
Unlike what I saw in some examples, I don't need to make request to Google services like Google Calendar or Tasks, I just want to authenticate the user.
Does someone could tell me what I need to do on the website and on the mobile app. Should I store information in my database? How to ensure that after authentication, all http requests from the mobile application are really from authenticated user?
Do not hesitate to ask me to clarify some points.
Thanks in advance
As OAuth is a standard for authorization and not for authentication, it doesn't support any direct method for this. However, most providers allow you to call an endpoint that returns the id of the logged in user. Google returns the id as part of the basic profile information. This step is described in the first article you already mentioned. There are multiple libraries available to simplify this step for you.
So for identifying a user you acquire his Google user id and store/match it in your database.
To get the user's id on an Android device, there's an even more simple way. Just use Google Play Services as described in its documentation. You can find the user id in the response to the call in the last section of the documentation.
Now there's still the problem that you have to send the user id from the device to your web server and verify that this call was issued by your app. Fortunately, Google has also built a method into Google Play Services for exactly this scenario. There's a blog post by Tim Bray at the Android Developers Blog about this.
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.