Skip to content

Commit aced090

Browse files
BenediktHainish
authored andcommitted
Add support for Google auth token as alternative to aas-token
1 parent 7aa5af6 commit aced090

5 files changed

Lines changed: 63 additions & 19 deletions

File tree

USAGE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Options:
2828
Google account email address (required if download source is Google Play)
2929
-t, --aas-token <google_aas_token>
3030
Google aas token (required if download source is Google Play)
31+
--auth-token <google_auth_token>
32+
Google auth token (alternative to aas-token, e.g., from Aurora dispenser)
3133
--accept-tos
3234
Accept Google Play Terms of Service
3335
-s, --sleep-duration <sleep_duration>

USAGE-google-play.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
To download directly from the Google Play Store, first you'll have to obtain an OAuth token by visiting the Google [embedded setup page](https://accounts.google.com/EmbeddedSetup) and:
1+
To download directly from the Google Play Store, you have two authentication options:
2+
3+
## Option 1: Using OAuth Token (recommended for personal accounts)
4+
5+
First, obtain an OAuth token by visiting the Google [embedded setup page](https://accounts.google.com/EmbeddedSetup) and:
26

37
- Open the browser debugging console to the `Network` tab
48
- Log in
@@ -20,7 +24,19 @@ An AAS token should be printed. You can use this to download an app:
2024
apkeep -a com.instagram.android -d google-play -e 'someone@gmail.com' -t some_aas_token .
2125
```
2226

23-
This will use a default device configuration of `px_9a`, a timezone of `UTC`, and a locale of `en_US`. To specify a different device profile, use the `-o` option:
27+
## Option 2: Using AUTH Token (for token dispensers)
28+
29+
If you have an AUTH token from a token dispenser (e.g., Aurora Store's dispenser), you can use it directly with the `--auth-token` flag:
30+
31+
```shell
32+
apkeep -a com.instagram.android -d google-play -e 'dispenser_email@gmail.com' --auth-token 'ya29.a0...' --accept-tos .
33+
```
34+
35+
AUTH tokens typically start with `ya29.`. The `--accept-tos` flag is recommended for first-time use with a new account to automatically accept Google Play's Terms of Service.
36+
37+
## Device Configuration
38+
39+
Both options will use a default device configuration of `px_9a`, a timezone of `UTC`, and a locale of `en_US`. To specify a different device profile, use the `-o` option:
2440

2541
```shell
2642
apkeep -a com.instagram.android -d google-play -o device=ad_g3_pro -e 'someone@gmail.com' -t some_aas_token .
@@ -62,12 +78,14 @@ A full list of options:
6278
* `include_dex_metadata`: when set to `1` or `true`, attempts to download the DexMetadata (dm) file for an app, which contains the apps' cloud profile
6379
* `include_additional_files`: when set to `1` or `true`, attempts to download any [additional `obb` expansion files](https://developer.android.com/google/play/expansion-files) for the app
6480

65-
If you prefer not to provide your credentials on the command line, you can specify them in a config file named `apkeep.ini`. This config file may have to be created, and must be located in the user config directory under the subpath `apkeep`. Usually on Linux systems this will be `~/.config/apkeep/apkeep.ini`. In this file specify your email and/or AAS token:
81+
If you prefer not to provide your credentials on the command line, you can specify them in a config file named `apkeep.ini`. This config file may have to be created, and must be located in the user config directory under the subpath `apkeep`. Usually on Linux systems this will be `~/.config/apkeep/apkeep.ini`. In this file specify your email and token:
6682

6783
```ini
6884
[google]
6985
email = someone@gmail.com
7086
aas_token = some_aas_token
87+
# OR use auth_token instead of aas_token:
88+
# auth_token = ya29.a0...
7189
```
7290

7391
Optionally, the path to this `ini` file can be specified:

src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ pub fn app() -> Command {
123123
.short('t')
124124
.long("aas-token")
125125
.action(ArgAction::Set)
126+
.conflicts_with("google_auth_token")
127+
)
128+
.arg(
129+
Arg::new("google_auth_token")
130+
.help("Google auth token (alternative to aas-token, e.g., from Aurora dispenser)")
131+
.long("auth-token")
132+
.action(ArgAction::Set)
133+
.conflicts_with("google_aas_token")
126134
)
127135
.arg(
128136
Arg::new("google_accept_tos")

src/download_sources/google_play.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ pub async fn download_apps(
1515
parallel: usize,
1616
sleep_duration: u64,
1717
email: &str,
18-
aas_token: &str,
18+
aas_token: Option<&str>,
19+
auth_token: Option<&str>,
1920
outpath: &Path,
2021
accept_tos: bool,
2122
mut options: HashMap<&str, &str>,
@@ -44,21 +45,25 @@ pub async fn download_apps(
4445
gpa.set_timezone(timezone);
4546
}
4647

47-
gpa.set_aas_token(aas_token);
48+
// Set the appropriate token type
49+
if let Some(aas) = aas_token {
50+
gpa.set_aas_token(aas);
51+
} else if let Some(auth) = auth_token {
52+
gpa.set_auth_token(auth);
53+
} else {
54+
eprintln!("Either AAS token or AUTH token must be provided");
55+
std::process::exit(1);
56+
}
4857
if let Err(err) = gpa.login().await {
4958
match err.kind() {
5059
GpapiErrorKind::TermsOfService => {
5160
if accept_tos {
5261
match gpa.accept_tos().await {
5362
Ok(_) => {
54-
if let Err(_) = gpa.login().await {
55-
eprintln!("Could not log in, even after accepting the Google Play Terms of Service");
56-
std::process::exit(1);
57-
}
5863
println!("Google Play Terms of Service accepted.");
5964
},
60-
_ => {
61-
eprintln!("Could not accept Google Play Terms of Service");
65+
Err(e) => {
66+
eprintln!("Could not accept Google Play Terms of Service: {}", e);
6267
std::process::exit(1);
6368
},
6469
}

src/main.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ async fn main() {
322322
).await;
323323
} else {
324324
let mut aas_token = matches.get_one::<String>("google_aas_token").map(|v| v.to_string());
325+
let mut auth_token = matches.get_one::<String>("google_auth_token").map(|v| v.to_string());
325326
let accept_tos = match matches.get_one::<bool>("google_accept_tos") {
326327
Some(true) => true,
327328
_ => false,
@@ -339,13 +340,16 @@ async fn main() {
339340
}
340341
});
341342

342-
if email.is_none() || aas_token.is_none() {
343+
if email.is_none() || (aas_token.is_none() && auth_token.is_none()) {
343344
if let Ok(conf) = load_config(ini_file) {
344345
if email.is_none() {
345346
email = conf.get("google", "email");
346347
}
347-
if aas_token.is_none() {
348+
if aas_token.is_none() && auth_token.is_none() {
348349
aas_token = conf.get("google", "aas_token");
350+
if aas_token.is_none() {
351+
auth_token = conf.get("google", "auth_token");
352+
}
349353
}
350354
}
351355
}
@@ -358,20 +362,27 @@ async fn main() {
358362
email = Some(prompt_email.trim().to_string());
359363
}
360364

361-
if aas_token.is_none() {
362-
let mut prompt_aas_token = String::new();
363-
print!("AAS Token: ");
365+
if aas_token.is_none() && auth_token.is_none() {
366+
let mut prompt_token = String::new();
367+
print!("AAS Token (or AUTH Token): ");
364368
io::stdout().flush().unwrap();
365-
io::stdin().read_line(&mut prompt_aas_token).unwrap();
366-
aas_token = Some(prompt_aas_token.trim().to_string());
369+
io::stdin().read_line(&mut prompt_token).unwrap();
370+
let token = prompt_token.trim().to_string();
371+
// Heuristic: AUTH tokens typically start with "ya29."
372+
if token.starts_with("ya29.") {
373+
auth_token = Some(token);
374+
} else {
375+
aas_token = Some(token);
376+
}
367377
}
368378

369379
google_play::download_apps(
370380
list,
371381
parallel,
372382
sleep_duration,
373383
&email.unwrap(),
374-
&aas_token.unwrap(),
384+
aas_token.as_deref(),
385+
auth_token.as_deref(),
375386
&outpath.unwrap(),
376387
accept_tos,
377388
options,

0 commit comments

Comments
 (0)