What is OAuth 2.0?

Android OAuth2

OAuth 2.0 is a industry standard authentication framework, that’ll allow your app limited access to user information using token! This token expires after some time period and a new token is demanded whenever your app need access to user information.

Getting Started with Android OAuth2 Project!

In this Android OAuth2 Example blog, we’ve used Google Search Console API in the following example to build an app that allows user to monitor their website performance on Google Search.

In the code above we are creating a browser intent with following url: https://accounts.google.com/o/oauth2/v2/auth and passing CLIENT_ID, CODE, REDIRECT_URI and OAUTH_SCOPE.

Now, once user of your app Authenticates your request, the response is received back from Server. But its not a straight forward process when it coems to OAuth 2.0 Authorization.

Creating required Classes

We’ll first get an Access Token, this will be used to get Authorization Token, Authorization token is the one that’ll be used to access user data. But once authorization token is expired then another refresh token is used to get another authorization token to access user data again!

Feeling overwhelmed? Let’s first create a Class for OAuth Server named OAuthServer.java