{"id":15645752,"url":"https://github.com/int128/oauth2cli","last_synced_at":"2025-11-23T10:05:14.236Z","repository":{"id":37979451,"uuid":"151343458","full_name":"int128/oauth2cli","owner":"int128","description":"Go package of OAuth 2.0 authorization for command line tools, which allows simple authorization flow for better UX","archived":false,"fork":false,"pushed_at":"2025-03-19T12:14:26.000Z","size":475,"stargazers_count":55,"open_issues_count":8,"forks_count":20,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T20:07:27.474Z","etag":null,"topics":["cli","golang","oauth2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int128.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-03T00:54:24.000Z","updated_at":"2025-03-19T12:13:55.000Z","dependencies_parsed_at":"2023-12-17T11:24:06.997Z","dependency_job_id":"138eb38c-f5e0-402f-ab40-349a83e4de69","html_url":"https://github.com/int128/oauth2cli","commit_stats":{"total_commits":228,"total_committers":5,"mean_commits":45.6,"dds":0.4605263157894737,"last_synced_commit":"ded1e8f02386311261cc6e63ee4e93c247a76c41"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Foauth2cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Foauth2cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Foauth2cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Foauth2cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int128","download_url":"https://codeload.github.com/int128/oauth2cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249525,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","golang","oauth2"],"created_at":"2024-10-03T12:09:38.817Z","updated_at":"2025-11-23T10:05:14.231Z","avatar_url":"https://github.com/int128.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth2cli ![go](https://github.com/int128/oauth2cli/workflows/go/badge.svg) [![GoDoc](https://godoc.org/github.com/int128/oauth2cli?status.svg)](https://godoc.org/github.com/int128/oauth2cli)\n\nThis is a Go package for OAuth 2.0 authorization in a command line interface (CLI) tool.\nYou can create a CLI tool with the simple authorization flow for better UX.\n\nTake a look at the screencast of [the example application](example/).\n\n\u003cimg src=\"https://user-images.githubusercontent.com/321266/87224372-c2a53c00-c3bf-11ea-8419-74380a9e681e.gif\" width=\"572\" height=\"391\"\u003e\n\n\n## Purpose\n\nWhen we create a CLI tool which accesses an API with OAuth, it needs the complicated flow such as copy/paste of a URL and code, as follows:\n\n1. User runs the command.\n1. Command shows the URL for authorization.\n1. User opens the browser, logs in to the server and approves the authorization.\n1. Server shows an authorization code.\n1. User copies the code and pastes into the command.\n1. Command accesses the API with the token.\n\nYou can make it simple by using oauth2cli as follows:\n\n1. User runs the command.\n1. Command opens the browser.\n1. User logs in to the server and approves the authorization.\n1. Command gets a token and access the API with the token.\n\n\n## How it works\n\noauth2cli starts the local server and initiates the flow of [OAuth 2.0 Authorization Code Grant](https://tools.ietf.org/html/rfc6749#section-4.1).\n\n### Testing OAuth 2.0 Auth Code Flow using oauth2cli\n\n```mermaid\nsequenceDiagram\n    autonumber\n    participant RO as Resource Owner (User)\n    participant CLI as oauth2cli\n    participant UA as User Agent (Browser)\n    participant Client as Local Server \u003cbr/\u003e (client)\n    participant AS as Auth Server\n\n    Note over Client,RO: (Prereq) Client registered with Authorization Server and has client_id\n\n    RO-\u003e\u003eCLI: Command\n    CLI-\u003e\u003eUA: Open\n    UA-\u003e\u003eAS: Authorization Request\n    AS--\u003e\u003eUA: Login / Consent\n    RO-\u003e\u003eUA: AuthN/AuthZ\n    UA-\u003e\u003eAS: AuthN/AuthZ\n    AS--\u003e\u003eUA: AuthZ Response (redirect)\n    UA-\u003e\u003eClient: Follow redirect\n    Client--\u003e\u003eUA: Success Response\n    UA--\u003e\u003eCLI: Close\n    CLI-\u003e\u003eAS: Token Request\n    AS-\u003e\u003eCLI: Token Response\n    CLI--\u003e\u003eRO: Exit\n```\n\n## Contributions\n\nThis is an open source software licensed under Apache 2.0.\nFeel free to open issues and pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Foauth2cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint128%2Foauth2cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Foauth2cli/lists"}