@@ -1068,28 +1068,43 @@ public final class AuthClient: @unchecked Sendable {
10681068 try await user ( ) . identities ?? [ ]
10691069 }
10701070
1071- /// Gets an URL that can be used for manual linking identity.
1071+ /// Returns the URL to link the user's identity with an OAuth provider.
1072+ ///
1073+ /// This method supports the PKCE flow.
1074+ ///
10721075 /// - Parameters:
10731076 /// - provider: The provider you want to link the user with.
10741077 /// - scopes: The scopes to request from the OAuth provider.
10751078 /// - redirectTo: The redirect URL to use, specify a configured deep link.
10761079 /// - queryParams: Additional query parameters to use.
1077- /// - Returns: A URL that you can use to initiate the OAuth flow.
1078- ///
1079- /// - Warning: This method is experimental and is expected to change.
1080- public func _getURLForLinkIdentity(
1080+ public func getLinkIdentityURL(
10811081 provider: Provider ,
10821082 scopes: String ? = nil ,
10831083 redirectTo: URL ? = nil ,
10841084 queryParams: [ ( name: String , value: String ? ) ] = [ ]
1085- ) throws -> URL {
1086- try getURLForProvider (
1085+ ) async throws -> OAuthResponse {
1086+ let url = try getURLForProvider (
10871087 url: configuration. url. appendingPathComponent ( " user/identities/authorize " ) ,
10881088 provider: provider,
10891089 scopes: scopes,
10901090 redirectTo: redirectTo,
1091- queryParams: queryParams
1091+ queryParams: queryParams,
1092+ skipBrowserRedirect: true
1093+ )
1094+
1095+ struct Response : Codable {
1096+ let url : URL
1097+ }
1098+
1099+ let response = try await api. authorizedExecute (
1100+ Request (
1101+ url: url,
1102+ method: . get
1103+ )
10921104 )
1105+ . decoded ( as: Response . self, decoder: configuration. decoder)
1106+
1107+ return OAuthResponse ( provider: provider, url: response. url)
10931108 }
10941109
10951110 /// Unlinks an identity from a user by deleting it. The user will no longer be able to sign in
@@ -1202,7 +1217,8 @@ public final class AuthClient: @unchecked Sendable {
12021217 provider: Provider ,
12031218 scopes: String ? = nil ,
12041219 redirectTo: URL ? = nil ,
1205- queryParams: [ ( name: String , value: String ? ) ] = [ ]
1220+ queryParams: [ ( name: String , value: String ? ) ] = [ ] ,
1221+ skipBrowserRedirect: Bool ? = nil
12061222 ) throws -> URL {
12071223 guard
12081224 var components = URLComponents (
@@ -1234,6 +1250,10 @@ public final class AuthClient: @unchecked Sendable {
12341250 queryItems. append ( URLQueryItem ( name: " code_challenge_method " , value: codeChallengeMethod) )
12351251 }
12361252
1253+ if let skipBrowserRedirect {
1254+ queryItems. append ( URLQueryItem ( name: " skip_http_redirect " , value: " \( skipBrowserRedirect) " ) )
1255+ }
1256+
12371257 queryItems. append ( contentsOf: queryParams. map ( URLQueryItem . init) )
12381258
12391259 components. queryItems = queryItems
0 commit comments