CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-google-auth-oauthlib

Google Authentication Library - oauthlib integration for OAuth 2.0 flows.

83

1.05x
Overview
Eval results
Files

task.mdevals/scenario-7/

Desktop OAuth Authenticator

Create a desktop application that performs OAuth 2.0 authentication for accessing Google APIs.

Requirements

Your implementation must:

  1. Load OAuth Configuration: Read OAuth client configuration from a JSON file at path client_secrets.json in the current directory
  2. Perform OAuth Flow: Execute an OAuth 2.0 authorization flow for a desktop application that:
    • Opens the user's default web browser to the authorization page
    • Runs a local server on port 8080 to receive the authorization callback
    • Requests the following scopes: https://www.googleapis.com/auth/userinfo.email and https://www.googleapis.com/auth/userinfo.profile
  3. Return Credentials: After successful authentication, return the credentials object that can be used with Google API client libraries
  4. Save Credentials: Save the obtained credentials to a file named credentials.json in JSON format for future use

Implementation Details

  • Create a module with a function authenticate() that performs the OAuth flow and returns credentials
  • The function should load client configuration from client_secrets.json
  • The function should run a local authorization server and open the browser automatically
  • After authentication, save the credentials in JSON format to credentials.json
  • The credentials should contain access token, refresh token, and token metadata

Test Cases

  • Loading client configuration from client_secrets.json succeeds @test
  • The OAuth flow successfully obtains credentials with access and refresh tokens @test
  • The credentials are properly saved to credentials.json in JSON format @test

Implementation

@generates

API

def authenticate():
    """
    Performs OAuth 2.0 authentication flow for a desktop application.

    Loads client configuration from client_secrets.json, runs an OAuth flow
    with a local server on port 8080, opens the browser for user authorization,
    and saves the obtained credentials to credentials.json.

    Returns:
        google.oauth2.credentials.Credentials: Authenticated credentials
    """
    pass

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 authentication flow support for desktop applications.

Install with Tessl CLI

npx tessl i tessl/pypi-google-auth-oauthlib

tile.json