Simple library that can be used to get access some non-public Google APIs as an Android Device.
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):
-
Go here, log in to your Google account and agree to the terms
-
Find the
oauth_token
inside theCookies
menu and copy the token from theContent
field
-
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
- 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
Available here
<dependency>
<groupId>io.github.rukins</groupId>
<artifactId>gpsoauth</artifactId>
</dependency>
implementation group: 'io.github.rukins', name: 'gpsoauth'
implementation("io.github.rukins:gpsoauth")
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());
}
}
curl -i -X GET -H "Authorization: OAuth ya29.***" "https://www.googleapis.com/notes/v1/changes"
In the Issues section you can suggest any improvements and report any bugs you find
This is an open-source project and all contributions are highly welcomed
Released under MIT License