using-oauth2

Registers OAuth2 apps, completes authorization, and calls APIs with access tokens.

5.0k|557|Updated May 14, 2025
One-click install
npx skills add https://github.com/dtyq/magic --skill using-oauth2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-oauth2
Source: https://github.com/dtyq/magic/tree/main/backend/super-magic/agents/skills/using-oauth2
Command: npx skills add https://github.com/dtyq/magic --skill using-oauth2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Connecting to third-party APIs that require OAuth2 authorization involves juggling app registration, redirect URIs, token exchange, and token injection into HTTP requests. This Skill handles that entire flow so you can call OAuth2-protected business APIs without manually managing credentials.

Core Features & Use Cases

  • OAuth2 App Lifecycle Management: Register, update, list, and remove user-provided OAuth2 apps, then start and check authorization sessions with automatic background token exchange.
  • Visible Business API Requests: Send GET, POST, PUT, PATCH, or DELETE requests through the oauth2_request transport, which injects the access token and shows a request card to the user.
  • Reusable API Documentation Library: Search, load, and record OpenAPI operation definitions for each app so future calls reuse verified request shapes.
  • Use Case: A user provides their company's OAuth2 client credentials for an internal API. The Skill registers the app, surfaces the redirect URI, guides the user through authorization, and then queries the API with the obtained access token.

Quick Start

Connect to my OAuth2 app using these client credentials, complete the authorization, and then call the user profile endpoint for me.

Frequently Asked Questions about using-oauth2

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call an API that requires OAuth2 authorization?

Register the app with oauth2_upsert_app, start authorization with oauth2_start_authorization, and have the user complete the consent flow. Then send business requests through oauth2_request, which injects the access token automatically.

How do I get an OAuth2 access token in Code Mode?

Use sdk.oauth2.get_access_token(app_name) inside run_python_snippet as a fallback when oauth2_request cannot express the request. If it raises OAuth2AuthorizationRequired, show the authorization URL and ask the user to authorize.

Does OAuth2 token injection support headers other than Authorization Bearer?

Yes. The auth parameter of oauth2_request supports type header with a custom header_name such as Access-Token and an optional prefix. Check the provider's documentation to determine the correct header format.

Why does OAuth2 authorization stay pending after the user consents?

A background checker exchanges the callback code for tokens while the pending session is valid. Call oauth2_check_authorization to confirm status; it is idempotent and returns authorized once the credential is saved.

What are the limitations of the oauth2_request tool?

It supports GET, POST, PUT, PATCH, and DELETE with query, JSON, or form bodies, and a maximum timeout of 120 seconds. For provider-specific request shapes it cannot express, fall back to get_access_token with a manual HTTP request.