OAuth2
The OAuth2 service collection provides operations for managing OAuth2 access tokens used to authenticate with the CrowdStrike API. All API requests require a valid bearer token generated through this collection. Use these operations to generate new access tokens and revoke previously issued tokens before their standard 30-minute expiry.
| Language | Last Update |
|---|---|
| Python | v1.3.2 |
| PowerShell | v2.2.9 |
| Go | v0.20.0 |
| TypeScript | v0.6.0 |
| Rust | v0.7.0 |
| Ruby | v1.2.0 |
Table of Contents
Section titled “Table of Contents”| Operation | Description |
|---|---|
oauth2RevokeTokenrevoke | Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan. |
oauth2AccessTokentoken | Generate an OAuth2 access token |
oauth2RevokeToken
Section titled “oauth2RevokeToken”Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan.
POST /oauth2/revoke
PEP 8
revokeParameters
Section titled “Parameters”| Name | Type | Data type | Description |
|---|---|---|---|
| data | formData | string | Full data payload in JSON format containing the OAuth2 access token you want to revoke. |
| client_id | formData | string | API client ID for the access token you want to revoke. Not Required |
| token | formData | string | The OAuth2 access token you want to revoke. |
Code Examples
Section titled “Code Examples”from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.revoke(client_id="string", token="string")print(response)from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.oauth2RevokeToken(client_id="string", token="string")print(response)from falconpy import APIHarnessV2
falcon = APIHarnessV2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.command("oauth2RevokeToken", client_id="string", token="string")print(response)Revoke-FalconTokenpackage main
import ( "context" "fmt" "os"
"github.com/crowdstrike/gofalcon/falcon" "github.com/crowdstrike/gofalcon/falcon/client/oauth2")
func main() { client, err := falcon.NewClient(&falcon.ApiConfig{ ClientId: os.Getenv("FALCON_CLIENT_ID"), ClientSecret: os.Getenv("FALCON_CLIENT_SECRET"), Context: context.Background(), }) if err != nil { panic(err) }
clientID := "string"
response, err := client.Oauth2.Oauth2RevokeToken( &oauth2.Oauth2RevokeTokenParams{ ClientID: &clientID, Token: "string", Context: context.Background(), }, ) if err != nil { panic(falcon.ErrorExplain(err)) }
fmt.Printf("%+v\n", response.Payload)}import { FalconClient } from "crowdstrike-falcon";
const client = new FalconClient({ cloud: process.env.FALCON_CLOUD!, clientId: process.env.FALCON_CLIENT_ID!, clientSecret: process.env.FALCON_CLIENT_SECRET!,});
const response = await client.oauth2.oauth2RevokeToken( "string", // token "string" // clientId);
console.log(response);use rusty_falcon::apis::oauth2_api::oauth2_revoke_token;use rusty_falcon::easy::client::FalconHandle;
#[tokio::main]async fn main() { let falcon = FalconHandle::from_env().await.expect("Could not authenticate");
let response = oauth2_revoke_token( &falcon.cfg, // configuration "string", // token Some("string"), // client_id ).await.expect("API call failed");
println!("{:?}", response);}require "crimson-falcon"
Falcon.configure do |config| config.client_id = ENV["FALCON_CLIENT_ID"] config.client_secret = ENV["FALCON_CLIENT_SECRET"] config.cloud = ENV["FALCON_CLOUD"]end
api = Falcon::Oauth2.new
response = api.oauth2_revoke_token('string')
puts responseoauth2AccessToken
Section titled “oauth2AccessToken”Generate an OAuth2 access token
POST /oauth2/token
PEP 8
tokenParameters
Section titled “Parameters”| Name | Type | Data type | Description |
|---|---|---|---|
| data | formData | string | Full data payload in JSON format containing your API credentials. CID scoping can also be provided here. |
Code Examples
Section titled “Code Examples”from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.token(client_id="string", client_secret="string", member_cid="string")print(response)from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.oauth2AccessToken(client_id="string", client_secret="string", member_cid="string")print(response)from falconpy import APIHarnessV2
falcon = APIHarnessV2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.command("oauth2AccessToken", client_id="string", client_secret="string", member_cid="string")print(response)Request-FalconTokenpackage main
import ( "context" "fmt" "os"
"github.com/crowdstrike/gofalcon/falcon" "github.com/crowdstrike/gofalcon/falcon/client/oauth2")
func main() { client, err := falcon.NewClient(&falcon.ApiConfig{ ClientId: os.Getenv("FALCON_CLIENT_ID"), ClientSecret: os.Getenv("FALCON_CLIENT_SECRET"), Context: context.Background(), }) if err != nil { panic(err) }
memberCid := "string"
response, err := client.Oauth2.Oauth2AccessToken( &oauth2.Oauth2AccessTokenParams{ ClientID: "string", ClientSecret: "string", MemberCid: &memberCid, Context: context.Background(), }, ) if err != nil { panic(falcon.ErrorExplain(err)) }
fmt.Printf("%+v\n", response.Payload)}import { FalconClient } from "crowdstrike-falcon";
const client = new FalconClient({ cloud: process.env.FALCON_CLOUD!, clientId: process.env.FALCON_CLIENT_ID!, clientSecret: process.env.FALCON_CLIENT_SECRET!,});
const response = await client.oauth2.oauth2AccessToken( "string", // clientId "string", // clientSecret "string" // memberCid);
console.log(response);use rusty_falcon::apis::oauth2_api::oauth2_access_token;use rusty_falcon::easy::client::FalconHandle;
#[tokio::main]async fn main() { let falcon = FalconHandle::from_env().await.expect("Could not authenticate");
let response = oauth2_access_token( &falcon.cfg, // configuration "string", // client_id "string", // client_secret Some("string"), // member_cid ).await.expect("API call failed");
println!("{:?}", response);}require "crimson-falcon"
Falcon.configure do |config| config.client_id = ENV["FALCON_CLIENT_ID"] config.client_secret = ENV["FALCON_CLIENT_SECRET"] config.cloud = ENV["FALCON_CLOUD"]end
api = Falcon::Oauth2.new
response = api.oauth2_access_token('string', 'string')
puts response