Cancel a grant request
Última revisión: 3 nov 2026
Esta página aún no está disponible en tu idioma.
If your client no longer needs access to protected resources, the Cancel Grant API lets you cancel (revoke) the corresponding grant request.
The code snippets below let a client cancel a previously issued grant. When cancelled, the request is placed into a finalized state and no further updates to the grant request are allowed.
Before you begin
Section titled “Before you begin”We recommend you create an account on the Interledger test network. Creating an account allows you to test your client against the Open Payments APIs by using an ILP-enabled wallet funded with play money.
Revoke a grant request
Section titled “Revoke a grant request”Prerequisites(opens in a new tab)
Initial configuration
If you’re using JavaScript, only do the first step.
-
Add
"type": "module"topackage.json. -
Add the following to
tsconfig.json{"compilerOptions": {"target": "ES2022","module": "ES2022"}}
// Import dependenciesimport { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize clientconst client = await createAuthenticatedClient({ walletAddressUrl: CLIENT_WALLET_ADDRESS, privateKey: PRIVATE_KEY_PATH, keyId: KEY_ID})
// Revoke grantawait client.grant.cancel({ accessToken: CONTINUE_ACCESS_TOKEN, url: CONTINUE_URI})Prerequisites(opens in a new tab)
// Import dependenciesuse open_payments::client::AuthenticatedResources;
// Initialize clientlet client = create_authenticated_client()?;
// Revoke grantlet access_token = get_env_var("CONTINUE_ACCESS_TOKEN")?;let continue_uri = get_env_var("CONTINUE_URI")?;
client .grant() .cancel(&continue_uri, Some(&access_token)) .await?;Prerequisites(opens in a new tab)
// Import dependenciesuse OpenPayments\AuthClient;use OpenPayments\Config\Config;
// Initialize client$config = new Config( $WALLET_ADDRESS, $PRIVATE_KEY, $KEY_ID);$opClient = new AuthClient($config);
// Revoke grant$response = $opClient->grant()->cancel( [ 'access_token'=> $ACCESS_TOKEN, 'url' => $CONTINUE_URI ]);Prerequisites(opens in a new tab)
package main
// Import dependenciesimport ( "context" "fmt" "log"
op "github.com/interledger/open-payments-go")
func main() { // Initialize client client, err := op.NewAuthenticatedClient(WALLET_ADDRESS_URL, PRIVATE_KEY_BASE_64, KEY_ID) if err != nil { log.Fatalf("Error creating authenticated client: %v\n", err) }
// Revoke grant if err := client.Grant.Cancel(context.TODO(), op.GrantCancelParams{ URL: CONTINUE_URI, AccessToken: CONTINUE_ACCESS_TOKEN, }); err != nil { log.Fatalf("Error revoking grant: %v\n", err) }
// Output fmt.Println("Grant revoked successfully")}Prerequisites(opens in a new tab)
// Import dependenciesimport org.interledger.openpayments.httpclient.OpenPaymentsHttpClient;import org.interledger.openpayments.IOpenPaymentsClient;
// Initialize clientvar client = OpenPaymentsHttpClient.defaultClient("WalletAddress","PrivateKeyPEM","KeyId");
// Retrieve the walletsvar receiverWallet = client.walletAddress().get("https://cloudninebank.example.com/merchant");
// Create incoming paymentvar grantRequest = client.auth().grant().incomingPayment(receiverWallet);
// Revoke grantclient.auth().grant().cancel(grantRequest);
// Outputlog.info("CANCELLED: {}", grantRequest);Prerequisites(opens in a new tab)
// Import dependenciesusing Microsoft.Extensions.DependencyInjection;using OpenPayments.Sdk.Clients;using OpenPayments.Sdk.Extensions;using OpenPayments.Sdk.HttpSignatureUtils;
// Initialize clientvar client = new ServiceCollection() .UseOpenPayments(opts => { opts.UseAuthenticatedClient = true; opts.KeyId = CLIENT_ID; opts.PrivateKey = KeyUtils.LoadPem(CLIENT_SECRET); opts.ClientUrl = new Uri(CLIENT_WALLET_ADDRESS); }) .BuildServiceProvider() .GetRequiredService<IAuthenticatedClient>();
// Revoke grantawait client.CancelGrantAsync( new AuthRequestArgs { Url = new Uri(CONTINUE_URI), AccessToken = CONTINUE_ACCESS_TOKEN });