Awesome
Unofficial Java client library for Google Play Services OAuth
Simple library that can be used to get access some non-public Google APIs as an Android Device.
Table of content
General info
Receiving an authentication token
To get a master token, firstly you need to receive an authentication token.
In a nutshell, you just need to obtain the value of the oauth_token
cookie after logging in to your Google account via https://accounts.google.com/EmbeddedSetup
Detailed instructions are provided below (I use Google Chrome, but I think the actions are similar in other browsers):
First way
-
Go here, log in to your Google account and agree to the terms
-
Find the
lock
-
Go to the
Cookies
section
-
Expand the
accounts.google.com
dropdown menu
-
Find the
oauth_token
inside theCookies
menu and copy the token from theContent
field
Second way
-
Go here, log in to your Google account and agree to the terms
-
Open
Developer tools
-
Go to the
Application
section and look forhttps://accounts.google.com
insideCookies
dropdown menu
-
Expand the
accounts.google.com
dropdown menu, find theoauth_token
and copy the Cookie value
Types of tokens
- Authentication token (starts with
oauth2_4/
) expires quickly, can be used only once - Master token (starts with
aas_et/
) never expires - Access token (starts with
ya29.
) expires in 1 hour
Download
Available here
Maven
<dependency>
<groupId>io.github.rukins</groupId>
<artifactId>gpsoauth</artifactId>
</dependency>
Gradle
implementation group: 'io.github.rukins', name: 'gpsoauth'
Gradle (Kotlin)
implementation("io.github.rukins:gpsoauth")
Simple example
import io.github.rukins.gpsoauth.Auth;
import io.github.rukins.gpsoauth.exception.AuthError;
import io.github.rukins.gpsoauth.model.MasterToken;
import io.github.rukins.gpsoauth.model.MasterTokenRequestParams;
public class Main {
public static void main(String[] args) {
Auth auth = new Auth();
MasterTokenRequestParams masterTokenRequestParams = MasterTokenRequestParams
.withDefaultValues()
.token("oauth2_4/***")
.build();
MasterToken masterToken;
try {
masterToken = auth.getMasterToken(masterTokenRequestParams);
} catch (AuthError e) {
System.out.println(e.getErrorObject());
return;
}
AccessTokenRequestParams accessTokenRequestParams = AccessTokenRequestParams
.withDefaultValues()
.masterToken(masterToken.getMasterToken())
.app("com.google.android.keep")
.scopes("oauth2:https://www.googleapis.com/auth/memento https://www.googleapis.com/auth/reminders")
.build();
AccessToken accessToken;
try {
accessToken = auth.getAccessToken(accessTokenRequestParams);
} catch (AuthError e) {
System.out.println(e.getErrorObject());
return;
}
System.out.println(masterToken.getMasterToken());
System.out.println(accessToken.getAccessToken());
}
}
And for example, request notes with an access token:
curl -i -X GET -H "Authorization: OAuth ya29.***" "https://www.googleapis.com/notes/v1/changes"
Report Issues
In the Issues section you can suggest any improvements and report any bugs you find
Contributing
This is an open-source project and all contributions are highly welcomed
License
Released under MIT License