Skip to content

Add OAuth authorization code flow to console app#12

Merged
Shane32 merged 2 commits intomasterfrom
copilot/add-user-authorization-option
Mar 30, 2026
Merged

Add OAuth authorization code flow to console app#12
Shane32 merged 2 commits intomasterfrom
copilot/add-user-authorization-option

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

The console app had no way to perform the initial OAuth authorization — users had to obtain tokens out-of-band. This adds a first-class 'o' (authorize) option that drives the full authorization code flow.

Changes

  • New 'o' option in the startup token prompt alongside existing 'a' (access token) and 'r' (refresh token) paths
  • AuthorizeAsync method that:
    • Constructs the Enphase auth URL with response_type=code, client_id, and the default redirect_uri (https://api.enphaseenergy.com/oauth/redirect_uri)
    • Opens the URL in the default system browser via Process.Start(..., UseShellExecute = true); degrades gracefully if the browser can't be launched
    • Prompts the user to paste the authorization code from the redirect URL
    • POSTs to /oauth/token with grant_type=authorization_code using Basic auth (base64 client_id:client_secret)
    • Prints the returned refresh token for the user to save for future runs
    • Returns the access_token to initialize the API client
Do you have an access token or refresh token, or do you need to authorize?
Enter 'a' for access, 'r' for refresh, or 'o' to authorize:

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add user authorization option to console app Add OAuth authorization code flow to console app Mar 30, 2026
Copilot AI requested a review from Shane32 March 30, 2026 02:44
@Shane32 Shane32 marked this pull request as ready for review March 30, 2026 04:21
@Shane32 Shane32 merged commit 6f84f26 into master Mar 30, 2026
4 checks passed
@Shane32 Shane32 deleted the copilot/add-user-authorization-option branch March 30, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants