Skip to content

Commit

Permalink
Fix Revoke OAuth Token
Browse files Browse the repository at this point in the history
Fixed the call to Revoke OAuth Token
  • Loading branch information
atejada committed Jul 25, 2024
1 parent 3ca6a84 commit 12624b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/main/kotlin/com/nylas/models/TokenParams.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.nylas.models

import com.squareup.moshi.Json

data class TokenParams(
/**
* Token to be revoked.
*/
@Json(name = "token")
val token: String,
) : IQueryParams
6 changes: 3 additions & 3 deletions src/main/kotlin/com/nylas/resources/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class Auth(private val client: NylasClient) {
*/
@Throws(NylasOAuthError::class, NylasSdkTimeoutError::class)
@JvmOverloads
fun revoke(token: String, overrides: RequestOverrides? = null): Boolean {
val path = "v3/connect/revoke?token=$token"
client.executePost<Any>(path, MutableMap::class.java, overrides = overrides)
fun revoke(token: TokenParams, overrides: RequestOverrides? = null): Boolean {
val path = "v3/connect/revoke"
client.executePost<Any>(path, MutableMap::class.java, queryParams = token, overrides = overrides)

return true
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/com/nylas/resources/AuthTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class AuthTests {
fun `revoke calls requests with the correct params`() {
val token = "user-token"

val res = auth.revoke(token)
val res = auth.revoke(TokenParams(token))

val pathCaptor = argumentCaptor<String>()
val typeCaptor = argumentCaptor<Type>()
Expand All @@ -327,7 +327,7 @@ class AuthTests {
overrideParamCaptor.capture(),
)

assertEquals("v3/connect/revoke?token=user-token", pathCaptor.firstValue)
assertEquals("v3/connect/revoke", pathCaptor.firstValue)
assertNull(requestBodyCaptor.firstValue)
assertEquals(true, res)
}
Expand Down

0 comments on commit 12624b7

Please sign in to comment.