Previous Topic

Next Topic

Deleting a Web Service Token

When a user logs out of Web Services, you can use MaxBasic to delete the token.

The Http Delete method will return a Response Code of 204 for a successful deletion, or 401 if the token is not found or not the appropriate type.

The following example function will delete a given access Token.

Note: You can change accesstokens to refreshtokens to delete a refresh token.

const URL = "InsertURLAsStringHere" 'Note: Add required URL here

'For example "http://YOUR_AUTH0_DOMAIN/oauth/"

Function DeleteCall(Token as String)

Dim Http as Object

Http = CreateObject("Accredo.HttpRequest")

Dim FinalUrl as String

FinalUrl = URL & "accesstokens/" & Token

' FinalUrl = URL & "refreshtokens/" & Token

FinalURL = URLEncode(FinalURL)

Http.URL = FinalURL

Http.ContentType = "application/json"

Dim Resp as String

Resp = Http.Delete

If Http.ResponseCode = 204 Then

Msgbox ("Token " & Token & " successfully deleted")

ElseIf Http.ResponseCode = 401 Then

Msgbox ("Token " & token & " not found or not appropriate type")

Else

Error ("Error making request. " & Http.ResponseCode & " - " & Http.ResponseText)

End If

End Function

See Also

Web Service

Book Contents

Book Index