pub struct KickOAuth { /* private fields */ }Expand description
Holds OAuth credentials and client for Kick.com
Implementations§
Source§impl KickOAuth
impl KickOAuth
Sourcepub fn from_env() -> Result<Self, Box<dyn Error>>
pub fn from_env() -> Result<Self, Box<dyn Error>>
Creates a new OAuth client by loading credentials from environment variables
Required env vars:
- KICK_CLIENT_ID
- KICK_CLIENT_SECRET
- KICK_REDIRECT_URI
Generates the authorization URL that users should visit
Pass the scopes you need (must match what you configured in your Kick app)
Returns (auth_url, csrf_token, pkce_verifier)
- auth_url: The URL to send the user to
- csrf_token: Save this! You’ll verify it matches when they return
- pkce_verifier: REQUIRED! Pass this to exchange_code() later
Sourcepub async fn exchange_code(
&self,
code: String,
pkce_verifier: PkceCodeVerifier,
) -> Result<OAuthTokenResponse, Box<dyn Error>>
pub async fn exchange_code( &self, code: String, pkce_verifier: PkceCodeVerifier, ) -> Result<OAuthTokenResponse, Box<dyn Error>>
Exchanges the authorization code for an access token
After the user authorizes, Kick redirects to your callback with a code parameter.
Pass that code AND the pkce_verifier from get_authorization_url() to this function.
Returns an OAuthTokenResponse with access_token, refresh_token, expires_in, etc.
Sourcepub async fn refresh_token(
&self,
refresh_token: &str,
) -> Result<OAuthTokenResponse, Box<dyn Error>>
pub async fn refresh_token( &self, refresh_token: &str, ) -> Result<OAuthTokenResponse, Box<dyn Error>>
Refresh an access token using a refresh token
When your access token expires, use the refresh token from the original
exchange_code() response to get a new one.
§Parameters
refresh_token: The refresh token from a previous token response