Skip to content

Commit 7b519d9

Browse files
committed
Added api of the delete method
1 parent c3c8219 commit 7b519d9

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

auth0/src/main/java/com/auth0/android/myaccount/MyAccountAPIClient.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,57 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
264264
return request
265265
}
266266

267+
268+
/**
269+
* Deletes an existing authentication method.
270+
*
271+
* ## Availability
272+
*
273+
* This feature is currently available in
274+
* [Early Access](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages#early-access).
275+
* Please reach out to Auth0 support to get it enabled for your tenant.
276+
*
277+
* ## Scopes Required
278+
* `delete:me:authentication-methods:passkey`
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.delete(authenticationMethodId, )
288+
* .start(object : Callback<Void, MyAccountException> {
289+
* override fun onSuccess(result: Void) {
290+
* Log.d("MyApp", "Authentication method deleted")
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 deleted
300+
*
301+
*/
302+
public fun delete(
303+
authenticationMethodId: String
304+
): Request<Void, MyAccountException> {
305+
val url =
306+
getDomainUrlBuilder()
307+
.addPathSegment(AUTHENTICATION_METHODS)
308+
.addPathSegment(authenticationMethodId)
309+
.build()
310+
311+
val request = factory.delete(url.toString(), GsonAdapter(Void::class.java))
312+
.addHeader(AUTHORIZATION_KEY, "Bearer $accessToken")
313+
314+
return request
315+
}
316+
317+
267318
private fun getDomainUrlBuilder(): HttpUrl.Builder {
268319
return auth0.getDomainUrl().toHttpUrl().newBuilder()
269320
.addPathSegment(ME_PATH)

0 commit comments

Comments
 (0)