OAuth2 - CrowdStrike/falconpy GitHub Wiki
Unlike regular Service Classes, the OAuth2 Service Class inherits from the FalconInterface
object, meaning the OAuth2 Service Class also represents the authorization object used by regular Service Classes for all authentication processing and state management.
Operation ID | Description | ||||
---|---|---|---|---|---|
|
Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan. | ||||
|
Generate an OAuth2 access token |
WARNING
client_id
andclient_secret
are keyword arguments that contain your CrowdStrike API credentials. Please note that all examples below do not hard code these values. (These values are ingested as strings.)CrowdStrike does not recommend hard coding API credentials or customer identifiers within source code.
Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan.
revoke
Method | Route |
---|---|
/oauth2/revoke |
- Consumes: application/x-www-form-urlencoded
- Produces: application/json
Name | Service | Uber | 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. |
from falconpy import OAuth2
# Do not hardcode API credentials!
falcon = OAuth2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.revoke(token="string", client_id="string")
print(response)
from falconpy import OAuth2
# Do not hardcode API credentials!
falcon = OAuth2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.oauth2RevokeToken(token="string", client_id="string")
print(response)
from falconpy import APIHarnessV2
# Do not hardcode API credentials!
falcon = APIHarnessV2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
PAYLOAD = {
"client_id": "string",
"token": "string"
}
response = falcon.command("oauth2RevokeToken", data=PAYLOAD)
print(response)
Generate an OAuth2 access token
token
Method | Route |
---|---|
/oauth2/token |
- Consumes: application/x-www-form-urlencoded
- Produces: application/json
Name | Service | Uber | Type | Data type | Description |
---|---|---|---|---|---|
data |
|
|
formData | string | Full data payload in JSON format containing your API credentials. CID scoping can also be provided here. |
This example will generate a token using the credentials provided when creating an instance of the Service Class.
from falconpy import OAuth2
# Do not hardcode API credentials!
falcon = OAuth2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.token()
print(response)
This example will generate a token using the credentials provided when creating an instance of the Service Class.
from falconpy import OAuth2
# Do not hardcode API credentials!
falcon = OAuth2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
response = falcon.oauth2AccessToken()
print(response)
This example demonstrates generating a token that is potentially different than the token generated when you create an instance of the Uber class.
from falconpy import APIHarnessV2
# Do not hardcode API credentials!
falcon = APIHarnessV2(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET
)
PAYLOAD = {
"client_id": "string",
"client_secret": "string",
"member_cid": "string"
}
response = falcon.command("oauth2AccessToken", data=PAYLOAD)
print(response)