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.6.5 |
| PowerShell | v2.2.9 |
| Go | v0.22.0 |
| TypeScript | v0.6.0 |
| Rust | v0.7.1 |
| Ruby | v1.4.0 |
Table of Contents
Section titled “Table of Contents”| Operation | Description |
|---|---|
oauth2AccessTokentoken | Generate an OAuth2 access token |
oauth2RevokeTokenrevoke | Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan. |
oauth2AccessToken
Section titled “oauth2AccessToken”Generate an OAuth2 access token
Method POST
Route /oauth2/token
PEP 8
tokenParameters
Section titled “Parameters”client_id body · string
The API client ID to authenticate your API requests. For information on generating API clients, see API documentation inside Falcon.
client_secret body · string
The API client secret to authenticate your API requests. For information on generating API clients, see API documentation inside Falcon.
member_cid body · string
For MSSP Master CIDs, optionally lock the token to act on behalf of this member CID
alter_state body · boolean
Flag indicating if the underlying authentication state is changed by this request.
Code Examples
from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.token(alter_state=boolean)print(response)from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.oauth2AccessToken(alter_state=boolean)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 responseResponses
{ "access_token": "string", "expires_in": 0, "id_token": "string", "issued_token_type": "string", "refresh_token": "string", "scope": "string", "token_type": "string"}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}oauth2RevokeToken
Section titled “oauth2RevokeToken”Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan.
Method POST
Route /oauth2/revoke
PEP 8
revokeParameters
Section titled “Parameters”client_id body · string
The OAuth2 client ID you are revoking the token for.
token body · string
The OAuth2 access token you want to revoke. Include your API client ID and secret in basic auth format (
Authorization: basic <encoded API client ID and secret>) in your request header.alter_state body · boolean
Flag indicating if the underlying authentication state is changed by this request.
Code Examples
from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.revoke(client_id="string", token="string", alter_state=boolean)print(response)from falconpy import OAuth2
falcon = OAuth2(client_id=CLIENT_ID, client_secret=CLIENT_SECRET )
response = falcon.oauth2RevokeToken(client_id="string", token="string", alter_state=boolean)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 responseResponses
{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}{ "errors": [ { "code": 0, "id": "string", "message": "string" } ], "meta": { "pagination": { "limit": 0, "offset": 0, "total": 0 }, "powered_by": "string", "query_time": 0.0, "trace_id": "string", "writes": { "resources_affected": 0 } }}