gleetube/oauth2
Types
OAuth2 configuration for Google/YouTube authentication.
pub type OAuthConfig {
OAuthConfig(
client_id: String,
client_secret: String,
redirect_uri: String,
scopes: List(String),
)
}
Constructors
-
OAuthConfig( client_id: String, client_secret: String, redirect_uri: String, scopes: List(String), )
Values
pub fn authorize_url(
config: OAuthConfig,
access_type access_type: option.Option(String),
state state: option.Option(String),
login_hint login_hint: option.Option(String),
prompt prompt: option.Option(Prompt),
) -> String
Build the Google OAuth2 authorization URL. Users should be redirected to this URL to begin the OAuth flow.
pub fn exchange_code(
config: OAuthConfig,
code code: String,
) -> Result(auth.AccessToken, error.GleeTubeError)
Exchange an authorization code for an access token.
pub fn get_profile(
access_token access_token: String,
) -> Result(auth.UserProfile, error.GleeTubeError)
Get the authenticated user’s profile.
pub fn new(
client_id client_id: String,
client_secret client_secret: String,
redirect_uri redirect_uri: String,
) -> OAuthConfig
Create a new OAuth2 config.
pub fn refresh_token(
config: OAuthConfig,
refresh_token refresh_token: String,
) -> Result(auth.AccessToken, error.GleeTubeError)
Refresh an expired access token using a refresh token.
pub fn revoke_token(
token token: String,
) -> Result(Nil, error.GleeTubeError)
Revoke an access or refresh token.
pub fn with_scopes(
config: OAuthConfig,
scopes: List(String),
) -> OAuthConfig
Set the scopes for OAuth2 authorization.
pub const youtube_force_ssl_scope: String
pub const youtube_readonly_scope: String
pub const youtube_upload_scope: String