Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the authentication issue when auto_login is set to true #56

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Demo/Demo/Demo-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>smartdrive</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class AliyunpanAuthenticator: NSObject {
let urlString = url.absoluteString.replacingOccurrences(
of: "alipan.com/applink/authorize",
with: "alipan.com/o/oauth/authorize")
guard let url = URL(string: urlString + "&source=app_link") else {
// TODO: - auto_login 服务修复后需要去除主动 auto_login 参数
guard let url = URL(string: urlString + "&source=app_link&auto_login=true") else {
throw AliyunpanError.AuthorizeError.invalidAuthorizeURL
}
return try await startAuthenticationSession(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class AliyunpanPKCECredentials: AliyunpanCredentialsProtocol {
scope: scope,
response_type: "code",
code_challenge: codeChallenge,
code_challenge_method: "S256",
auto_login: "true")))
code_challenge_method: "S256")))
.response()
.redirectUri

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class AliyunpanServerCredentials: AliyunpanCredentialsProtocol {
client_id: appId,
redirect_uri: "oob",
scope: scope,
response_type: "code",
auto_login: "true")))
response_type: "code")))
.response()
.redirectUri

Expand Down
6 changes: 3 additions & 3 deletions Sources/AliyunpanSDK/AliyunpanScope/Internal/Authorize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extension AliyunpanInternalScope {
/// h5下true强制用户登录,默认false
public let relogin: Bool?
public let source: String?
/// true 表示已授权后,后续无需用户主动点击授权。默认 false
public let auto_login: String
/// 已授权后,后续无需用户主动点击授权。true 开启,nil 关闭,默认 nil
public let auto_login: String?

public init(client_id: String, redirect_uri: String, scope: String, response_type: String, code_challenge: String? = nil, code_challenge_method: String? = nil, state: String? = nil, relogin: Bool? = nil, bundle_id: String = Bundle.main.bundleId, source: String? = "appLink", auto_login: String = "false") {
public init(client_id: String, redirect_uri: String, scope: String, response_type: String, code_challenge: String? = nil, code_challenge_method: String? = nil, state: String? = nil, relogin: Bool? = nil, bundle_id: String = Bundle.main.bundleId, source: String? = "appLink", auto_login: String? = nil) {
self.client_id = client_id
self.redirect_uri = redirect_uri
self.scope = scope
Expand Down