Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
AccessTokenInvalid and TokenExpired
Browse files Browse the repository at this point in the history
Update QPS for list and downloadurl
open.aliyundrive.com => openapi.aliyundrive.com
bump version to 3.1.0
  • Loading branch information
eritpchy committed May 25, 2023
1 parent 26fb009 commit ec1d6d5
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 29 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ implementation "com.squareup.okhttp3:logging-interceptor:3.12.13" //api19
implementation "com.google.code.gson:gson:2.8.9"
//主要
implementation "net.xdow:aliyundrive-sdk-openapi:1.0.5"
implementation "net.xdow:aliyundrive-sdk-webapi:1.0.5"
implementation "net.xdow:aliyundrive-sdk-openapi:1.0.6"
implementation "net.xdow:aliyundrive-sdk-webapi:1.0.6"
//可选
implementation "net.xdow:webdav:1.0.5"
implementation "net.xdow:webdav-jakarta:1.0.5"
implementation "net.xdow:webdav-javax:1.0.5"
implementation "net.xdow:aliyundrive-webdav-internal:1.0.5"
implementation "net.xdow:aliyundrive-android-core:1.0.5"
implementation "net.xdow:jap-http:1.0.5"
implementation "net.xdow:jap-http-jakarta-adapter:1.0.5"
implementation "net.xdow:jap-http-javax-adapter:1.0.5"
implementation "net.xdow:webdav:1.0.6"
implementation "net.xdow:webdav-jakarta:1.0.6"
implementation "net.xdow:webdav-javax:1.0.6"
implementation "net.xdow:aliyundrive-webdav-internal:1.0.6"
implementation "net.xdow:aliyundrive-android-core:1.0.6"
implementation "net.xdow:jap-http:1.0.6"
implementation "net.xdow:jap-http-jakarta-adapter:1.0.6"
implementation "net.xdow:jap-http-javax-adapter:1.0.6"
```
## 基础用法
```java
Expand Down
2 changes: 1 addition & 1 deletion aliyundrive-android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
apply plugin: 'com.android.library'

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive Webdav Android Core'

repositories {
Expand Down
2 changes: 1 addition & 1 deletion aliyundrive-sdk-openapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive OpenApi SDK'

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class AliyunDriveConstant {
public static final int MAX_DOWNLOAD_URL_EXPIRE_TIME_SEC = 115200; //32h
public static final int MAX_FILE_CREATE_PART_INFO_LIST_SIZE = 10000;
public static final String REFERER = "https://www.aliyundrive.com/";
public static final String API_HOST = "https://open.aliyundrive.com";
public static final String API_HOST = "https://openapi.aliyundrive.com";
public static final String API_ACCESS_TOKEN = API_HOST + "/oauth/access_token";
public static final String API_QRCODE_GENERATE = API_HOST + "/oauth/authorize/qrcode";
public static final String API_QRCODE_IMAGE = API_HOST + "/oauth/qrcode/%s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Response intercept(Chain chain) throws IOException {
if (code == 401 || code == 400) {
ResponseBody body = response.peekBody(40960);
String res = body.string();
if (res.contains("AccessTokenInvalid")) {
if (res.contains("AccessTokenInvalid") || res.contains("TokenExpired")) {
AliyunDriveOpenApiImplV1.this.requestNewAccessToken();
return chain.proceed(AliyunDriveOpenApiImplV1.this.buildCommonRequestHeader(request));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public void checkAuthorize(T t) {
if ("AccessTokenInvalid".equals(t.getCode())) {
throw new NotAuthenticatedException(t.getMessage() + "(" + t.getCode() + ")");
}
if ("TokenExpired".equals(t.getCode())) {
throw new NotAuthenticatedException(t.getMessage() + "(" + t.getCode() + ")");
}
}

public AliyunDriveCall<T> disableAuthorizeCheck() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Response intercept(Chain chain) throws IOException {
if (code == 401 || code == 400) {
ResponseBody body = response.peekBody(40960);
String res = body.string();
if (res.contains("AccessTokenInvalid")) {
if (res.contains("AccessTokenInvalid") || res.contains("TokenExpired")) {
listener.run();
}
}
Expand Down
2 changes: 1 addition & 1 deletion aliyundrive-sdk-webapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive WebApi SDK'

java {
Expand Down
2 changes: 1 addition & 1 deletion aliyundrive-webdav-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive Webdav internal'

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AliyunDriveProperties {
private transient String clientId;

private transient String authorizationCode;
private transient String aliyunAccessTokenUrl = "https://adrive.xdow.net/oauth/access_token?code=%s&refresh_token=%s&ver=1.0.5";
private transient String aliyunAccessTokenUrl = "https://adrive.xdow.net/oauth/access_token?code=%s&refresh_token=%s&ver=1.0.6";
private transient String aliyunAuthorizeUrl = "https://adrive.xdow.net/oauth/authorize?redirect_uri=%s";

private transient Auth auth = new Auth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private List<AliyunDriveFileInfo> fileListFromApi(String nodeId, String marker,
if (res.isError()) {
if ("TooManyRequests".equals(res.getCode())) {
try {
TimeUnit.SECONDS.sleep(6);
TimeUnit.MILLISECONDS.sleep(300);
} catch (InterruptedException e) {
}
res = this.mAliyunDrive.fileList(query).execute();
Expand All @@ -147,7 +147,7 @@ private List<AliyunDriveFileInfo> fileListFromApi(String nodeId, String marker,
if (res.isError()) {
if ("TooManyRequests".equals(res.getCode())) {
try {
TimeUnit.SECONDS.sleep(6);
TimeUnit.MILLISECONDS.sleep(300);
} catch (InterruptedException e) {
}
res = this.mAliyunDrive.fileList(query).execute();
Expand Down Expand Up @@ -468,7 +468,7 @@ private synchronized AliyunDriveResponse.FileGetDownloadUrlInfo fileGetDownloadU
if (res.isError()) {
if ("TooManyRequests".equals(res.getCode())) {
try {
TimeUnit.SECONDS.sleep(6);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
}
res = this.mAliyunDrive.fileGetDownloadUrl(query).execute();
Expand All @@ -477,7 +477,7 @@ private synchronized AliyunDriveResponse.FileGetDownloadUrlInfo fileGetDownloadU
if (res.isError()) {
if ("TooManyRequests".equals(res.getCode())) {
try {
TimeUnit.SECONDS.sleep(6);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
}
res = this.mAliyunDrive.fileGetDownloadUrl(query).execute();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'com.github'
version '3.0.8'
version '3.1.0'
sourceCompatibility = '17'

configurations {
Expand Down
2 changes: 1 addition & 1 deletion jap-http-adapter/jap-http-jakarta-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'jap-http servlet interface jakarta adapter'

java {
Expand Down
2 changes: 1 addition & 1 deletion jap-http-adapter/jap-http-javax-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'jap-http servlet interface javax adapter'

java {
Expand Down
2 changes: 1 addition & 1 deletion jap-http/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'jap-http servlet interface'

java {
Expand Down
2 changes: 1 addition & 1 deletion webdav-jakarta/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive Webdav jakarta implement'

java {
Expand Down
2 changes: 1 addition & 1 deletion webdav-javax/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive Webdav javax implement'

java {
Expand Down
2 changes: 1 addition & 1 deletion webdav/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.xdow'
version '1.0.5'
version '1.0.6'
description 'AliyunDrive Webdav core'

java {
Expand Down

0 comments on commit ec1d6d5

Please sign in to comment.