11package com.auth0.android.myaccount
22
33import androidx.annotation.VisibleForTesting
4+ import androidx.browser.customtabs.CustomTabsService.Result
45import com.auth0.android.Auth0
56import com.auth0.android.Auth0Exception
67import com.auth0.android.NetworkErrorException
@@ -14,6 +15,7 @@ import com.auth0.android.request.internal.GsonAdapter.Companion.forMap
1415import com.auth0.android.request.internal.GsonProvider
1516import com.auth0.android.request.internal.RequestFactory
1617import com.auth0.android.request.internal.ResponseUtils.isNetworkError
18+ import com.auth0.android.result.AuthenticationMethod
1719import com.auth0.android.result.PasskeyAuthenticationMethod
1820import com.auth0.android.result.PasskeyEnrollmentChallenge
1921import com.auth0.android.result.PasskeyRegistrationChallenge
@@ -244,7 +246,7 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
244246 " type" to " public-key" ,
245247 " response" to mapOf (
246248 " clientDataJSON" to credentials.response.clientDataJSON,
247- " attestationObject" to credentials.response.attestationObject
249+ " attestationObject" to credentials.response.attestationObject,
248250 )
249251 )
250252
@@ -266,7 +268,56 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
266268
267269
268270 /* *
269- * Deletes an existing authentication method.
271+ * Retrieves a single authentication method belonging to the user.
272+ *
273+ * ## Availability
274+ *
275+ * This feature is currently available in
276+ * [Early Access](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages#early-access).
277+ * Please reach out to Auth0 support to get it enabled for your tenant.
278+ *
279+ *
280+ * ## Usage
281+ *
282+ * ```kotlin
283+ * val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
284+ * val apiClient = MyAccountAPIClient(auth0, accessToken)
285+ *
286+ *
287+ * apiClient.getAuthenticationMethod(authenticationMethodId, )
288+ * .start(object : Callback<AuthenticationMethod, MyAccountException> {
289+ * override fun onSuccess(result: AuthenticationMethod) {
290+ * Log.d("MyApp", "Authentication method $result")
291+ * }
292+ *
293+ * override fun onFailure(error: MyAccountException) {
294+ * Log.e("MyApp", "Failed with: ${error.message}")
295+ * }
296+ * })
297+ * ```
298+ *
299+ * @param authenticationMethodId Id of the authentication method to be retrieved
300+ *
301+ */
302+ public fun getAuthenticationMethod (authenticationMethodId : String ): Result <AuthenticationMethod , MyAccountException > {
303+ val url =
304+ getDomainUrlBuilder()
305+ .addPathSegment(AUTHENTICATION_METHODS )
306+ .addPathSegment(authenticationMethodId)
307+ .build()
308+
309+ val request = factory.get(
310+ url.toString(),
311+ GsonAdapter (AuthenticationMethod ::class .java)
312+ )
313+ .addHeader(AUTHORIZATION_KEY , " Bearer $accessToken " )
314+
315+ return request
316+ }
317+
318+
319+ /* *
320+ * Deletes an existing authentication method belonging to the user.
270321 *
271322 * ## Availability
272323 *
@@ -284,7 +335,7 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
284335 * val apiClient = MyAccountAPIClient(auth0, accessToken)
285336 *
286337 *
287- * apiClient.delete (authenticationMethodId, )
338+ * apiClient.deleteAuthenticationMethod (authenticationMethodId, )
288339 * .start(object : Callback<Void, MyAccountException> {
289340 * override fun onSuccess(result: Void) {
290341 * Log.d("MyApp", "Authentication method deleted")
@@ -299,7 +350,7 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
299350 * @param authenticationMethodId Id of the authentication method to be deleted
300351 *
301352 */
302- public fun delete (
353+ public fun deleteAuthenticationMethod (
303354 authenticationMethodId : String
304355 ): Request <Void , MyAccountException > {
305356 val url =
0 commit comments