### Handle Redirect URL - Example Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 The redirect URL contains the authorization `code` and `state` (if provided) after a user authorizes your application. If authorization fails, an `error=true` parameter will be present. ```url https://oauth.it-really.rocks?code=hjqkweSNDSDQ2___12&state=ejlkqwj2u31u31i1 ``` -------------------------------- ### Generate Authorization URL - Example Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Constructs the authorization URL for the OAuth2 flow. It requires your `client_id`, `redirect_uri`, and specifies the `response_type` as 'code'. Optional parameters like `scope` and `state` can be included. ```url https://api.streamelements.com/oauth2/authorize?client_id=9d5422b8ff529d420&redirect_uri=https%3A%2F%2Foauth.it-really.rocks%2Fcallback&response_type=code&scope=channel%3Aread ``` -------------------------------- ### Make Authenticated API Request - cURL Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Demonstrates how to make an authenticated GET request to the StreamElements API using an OAuth2 access token. The token should be included in the `Authorization` header as `oAuth `. ```bash curl -X GET "https://api.streamelements.com/kappa/v2/channels/me" \ -H "Accept: application/json" \ -H "Authorization: oAuth 5a30c9621f638600014af608123" ``` -------------------------------- ### Validate OAuth2 Token - cURL Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Validates an OAuth2 access token by sending a GET request to the `/oauth2/validate` endpoint. The token is provided in the `Authorization` header. ```bash curl -H "Authorization: OAuth " https://api.streamelements.com/oauth2/validate ``` -------------------------------- ### OAuth2 Authorization Endpoint Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Initiates the OAuth2 authorization flow. Users are redirected to this endpoint to grant your application access to their StreamElements data. ```APIDOC ## GET /oauth2/authorize ### Description Initiates the OAuth2 authorization flow. Users are redirected to this endpoint to grant your application access to their StreamElements data. ### Method GET ### Endpoint https://api.streamelements.com/oauth2/authorize ### Parameters #### Query Parameters - **client_id** (string) - Required - Your registered client ID. - **redirect_uri** (URI) - Required - Your registered redirect URI. - **response_type** (string) - Required - Must be 'code'. - **scope** (string) - Optional - Space-separated list of scopes. - **state** (string) - Optional - A unique token generated by your application. ### Request Example ``` https://api.streamelements.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=channel:read ``` ### Response Upon user authorization, the user is redirected to your `redirect_uri` with a `code` and `state` parameter. If the user does not authorize, an `error=true` parameter is appended to the redirect URI. #### Response Example (Success Redirect) ``` YOUR_REDIRECT_URI?code=AUTHORIZATION_CODE&state=UNIQUE_STATE ``` #### Response Example (Error Redirect) ``` YOUR_REDIRECT_URI?error=true ``` ``` -------------------------------- ### OAuth2 Validation Endpoint Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Validates an access token. ```APIDOC ## GET /oauth2/validate ### Description Validates an access token to check if it is still active and has not expired. ### Method GET ### Endpoint https://api.streamelements.com/oauth2/validate ### Parameters #### Header Parameters - **Authorization** (string) - Required - Should be formatted as `OAuth `. ### Request Example ``` curl -H "Authorization: OAuth YOUR_ACCESS_TOKEN" https://api.streamelements.com/oauth2/validate ``` ### Response #### Success Response (200) Indicates a valid and active token. The response body may contain details about the token's validity or associated user information. ``` -------------------------------- ### OAuth2 Token Endpoint Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Exchanges an authorization code for an access token and refresh token, or refreshes an existing access token. ```APIDOC ## POST /oauth2/token ### Description Exchanges an authorization code for an access token and refresh token, or refreshes an existing access token. This endpoint is used for both initial token acquisition and token refreshing. ### Method POST ### Endpoint https://api.streamelements.com/oauth2/token ### Parameters #### Request Body - **grant_type** (string) - Required - Must be 'authorization_code' for initial acquisition or 'refresh_token' for refreshing. - **client_id** (string) - Required - Your registered client ID. - **client_secret** (string) - Required - Your registered client secret. - **code** (string) - Required (for 'authorization_code' grant_type) - The authorization code received from the authorization endpoint. - **redirect_uri** (URI) - Required (for 'authorization_code' grant_type) - Your registered redirect URI. - **refresh_token** (string) - Required (for 'refresh_token' grant_type) - Your current refresh token. ### Request Example (Authorization Code Grant) ``` curl -X POST "https://api.streamelements.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=authorization_code" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "code=AUTHORIZATION_CODE" \ -d "redirect_uri=YOUR_REDIRECT_URI" ``` ### Request Example (Refresh Token Grant) ``` curl -X POST "https://api.streamelements.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=refresh_token" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "refresh_token=YOUR_REFRESH_TOKEN" ``` ### Response #### Success Response (200) - **access_token** (string) - The user's access token. - **refresh_token** (string) - The user's refresh token. - **expires_in** (integer) - The lifetime in seconds of the access token. - **token_type** (string) - The type of token, usually 'Bearer'. #### Response Example ```json { "access_token": "ACCESS_TOKEN", "refresh_token": "REFRESH_TOKEN", "expires_in": 3600, "token_type": "Bearer" } ``` ``` -------------------------------- ### OAuth2 Token Revocation Endpoint Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Allows users to revoke access for your application. ```APIDOC ## POST /oauth2/revoke ### Description Allows users to revoke access for your application. This endpoint is typically used when a user wishes to disconnect your application from their StreamElements account. ### Method POST ### Endpoint https://api.streamelements.com/oauth2/revoke ### Parameters #### Request Body - **client_id** (string) - Required - Your registered client ID. - **token** (string) - Required - The access token or refresh token to revoke. ### Request Example ``` curl -X POST "https://api.streamelements.com/oauth2/revoke" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=YOUR_CLIENT_ID" \ -d "token=ACCESS_OR_REFRESH_TOKEN" ``` ### Response #### Success Response (200) Indicates successful revocation. The response body is typically empty or contains a confirmation message. ``` -------------------------------- ### Exchange Code for Access Token - cURL Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Exchanges the authorization code obtained from the redirect for a user access token. This POST request requires `grant_type`, `client_id`, `client_secret`, `code`, and `redirect_uri` in the `x-www-form-urlencoded` payload. ```bash curl -X POST "https://api.streamelements.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=authorization_code" \ -d "client_id=9d5422b8ff529d420" \ -d "client_secret=1234567890abcdef" \ -d "code=a1b2c3d4e5f6g7h8i9j0k" \ -d "redirect_uri=https://oauth.it-really.rocks" ``` -------------------------------- ### Revoke Token using cURL Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 This snippet demonstrates how to revoke an OAuth2 access token by sending a POST request to the StreamElements API. It requires your client ID and the access token to be revoked. A successful revocation results in a 200 OK status code. ```shell curl -X POST "https://api.streamelements.com/oauth2/revoke?client_id=9d5422b8ff529d420&token=" ``` -------------------------------- ### POST /oauth2/revoke Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Revoke an access token by sending a POST request to the revoke URL with your client ID and the token to be revoked. ```APIDOC ## POST /oauth2/revoke ### Description Revokes an access token. This is typically used when a user logs out or revokes access to your application. ### Method POST ### Endpoint https://api.streamelements.com/oauth2/revoke ### Parameters #### Query Parameters - **client_id** (string) - Required - Your registered client ID. - **token** (string) - Required - The access token to be revoked. ### Request Example ```curl curl -X POST "https://api.streamelements.com/oauth2/revoke?client_id=9d5422b8ff529d420&token=" ``` ### Response #### Success Response (200) No response body is sent upon successful revocation. The header will return a status code of 200 (OK). ``` -------------------------------- ### Refresh Access Token - cURL Source: https://dev.streamelements.com/docs/api-docs/cd02cda5171ea-o-auth2 Refreshes an expired access token using a `refresh_token`. This POST request to the token endpoint requires `grant_type` set to `refresh_token`, along with `client_id`, `client_secret`, and the `refresh_token`. ```bash curl -X POST "https://api.streamelements.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=refresh_token" \ -d "client_id=9d5422b8ff529d420" \ -d "client_secret=1234567890abcdef" \ -d "refresh_token=ed7a57c4cfbb540e5a30c9621f6386000" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.