@@ -1068,28 +1068,43 @@ public final class AuthClient: @unchecked Sendable {
1068
1068
try await user ( ) . identities ?? [ ]
1069
1069
}
1070
1070
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
+ ///
1072
1075
/// - Parameters:
1073
1076
/// - provider: The provider you want to link the user with.
1074
1077
/// - scopes: The scopes to request from the OAuth provider.
1075
1078
/// - redirectTo: The redirect URL to use, specify a configured deep link.
1076
1079
/// - 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(
1081
1081
provider: Provider ,
1082
1082
scopes: String ? = nil ,
1083
1083
redirectTo: URL ? = nil ,
1084
1084
queryParams: [ ( name: String , value: String ? ) ] = [ ]
1085
- ) throws -> URL {
1086
- try getURLForProvider (
1085
+ ) async throws -> OAuthResponse {
1086
+ let url = try getURLForProvider (
1087
1087
url: configuration. url. appendingPathComponent ( " user/identities/authorize " ) ,
1088
1088
provider: provider,
1089
1089
scopes: scopes,
1090
1090
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
+ )
1092
1104
)
1105
+ . decoded ( as: Response . self, decoder: configuration. decoder)
1106
+
1107
+ return OAuthResponse ( provider: provider, url: response. url)
1093
1108
}
1094
1109
1095
1110
/// 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 {
1202
1217
provider: Provider ,
1203
1218
scopes: String ? = nil ,
1204
1219
redirectTo: URL ? = nil ,
1205
- queryParams: [ ( name: String , value: String ? ) ] = [ ]
1220
+ queryParams: [ ( name: String , value: String ? ) ] = [ ] ,
1221
+ skipBrowserRedirect: Bool ? = nil
1206
1222
) throws -> URL {
1207
1223
guard
1208
1224
var components = URLComponents (
@@ -1234,6 +1250,10 @@ public final class AuthClient: @unchecked Sendable {
1234
1250
queryItems. append ( URLQueryItem ( name: " code_challenge_method " , value: codeChallengeMethod) )
1235
1251
}
1236
1252
1253
+ if let skipBrowserRedirect {
1254
+ queryItems. append ( URLQueryItem ( name: " skip_http_redirect " , value: " \( skipBrowserRedirect) " ) )
1255
+ }
1256
+
1237
1257
queryItems. append ( contentsOf: queryParams. map ( URLQueryItem . init) )
1238
1258
1239
1259
components. queryItems = queryItems
0 commit comments