Skip to content

Commit

Permalink
fix: fix the authentication issue when auto_login is set to true (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzxha authored May 16, 2024
1 parent d10e2a2 commit 88a7c5e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
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

0 comments on commit 88a7c5e

Please sign in to comment.