| 1 |
# Duke Energy OAuth Helper - Chrome Extension |
| 2 |
|
| 3 |
This Chrome extension captures OAuth authorization codes from Duke Energy's mobile app login flow, which uses a custom `cma-prod://` URL scheme that browsers cannot normally handle. |
| 4 |
|
| 5 |
## Why is this needed? |
| 6 |
|
| 7 |
Duke Energy's mobile app uses Auth0 for authentication with a custom redirect URI (`cma-prod://login.duke-energy.com/android/com.dukeenergy.customerapp.release/callback`). Standard browsers cannot handle this custom scheme, so this extension intercepts the redirect and captures the authorization code for you. |
| 8 |
|
| 9 |
## Installation |
| 10 |
|
| 11 |
1. Open Chrome and navigate to `chrome://extensions/` |
| 12 |
2. Enable "Developer mode" (toggle in the top right) |
| 13 |
3. Click "Load unpacked" |
| 14 |
4. Select this `chrome-extension` folder |
| 15 |
5. The extension icon should appear in your toolbar |
| 16 |
|
| 17 |
## Usage |
| 18 |
|
| 19 |
### With browser_auth.py script |
| 20 |
|
| 21 |
1. Run the `browser_auth.py` script: |
| 22 |
|
| 23 |
```bash |
| 24 |
cd examples |
| 25 |
python browser_auth.py |
| 26 |
``` |
| 27 |
|
| 28 |
2. The script will: |
| 29 |
|
| 30 |
- Generate an authorization URL |
| 31 |
- Open your browser to the Duke Energy login page |
| 32 |
- Wait for you to paste the authorization code |
| 33 |
|
| 34 |
3. Complete the login in your browser: |
| 35 |
|
| 36 |
- Enter your Duke Energy credentials |
| 37 |
- Complete any MFA/verification steps |
| 38 |
|
| 39 |
4. After successful login: |
| 40 |
|
| 41 |
- The extension will capture the `cma-prod://` redirect |
| 42 |
- A page will show with your authorization code |
| 43 |
- Copy the code |
| 44 |
|
| 45 |
5. Paste the code back into the terminal when prompted |
| 46 |
|
| 47 |
6. The script will exchange the code for Duke Energy API tokens |
| 48 |
|
| 49 |
### Manual Usage |
| 50 |
|
| 51 |
1. Open the extension popup to see if any code has been captured |
| 52 |
2. Click "View Full Details" to see the complete authorization data |
| 53 |
3. Click "Copy Code" to copy the authorization code to clipboard |
| 54 |
4. Click "Clear" to reset for a new login attempt |
| 55 |
|
| 56 |
## How it works |
| 57 |
|
| 58 |
1. When you complete the Duke Energy login, Auth0 redirects to `cma-prod://...?code=...` |
| 59 |
2. Chrome cannot handle this URL scheme and would normally show an error |
| 60 |
3. This extension intercepts that navigation attempt |
| 61 |
4. It extracts the `code` and `state` parameters |
| 62 |
5. It redirects you to a capture page showing the extracted data |
| 63 |
|
| 64 |
## Files |
| 65 |
|
| 66 |
- `manifest.json` - Extension configuration |
| 67 |
- `background.js` - Service worker that intercepts redirects |
| 68 |
- `popup.html` - Extension popup UI |
| 69 |
- `capture.html` - Page displayed after capturing the code |
| 70 |
|
| 71 |
## Security Notes |
| 72 |
|
| 73 |
- The authorization code is only stored temporarily in the extension |
| 74 |
- Codes expire after a few minutes and can only be used once |
| 75 |
- The extension only has permission to access Duke Energy login URLs |
| 76 |
- Use "Clear" to remove captured codes after use |
| 77 |
|
| 78 |
## Troubleshooting |
| 79 |
|
| 80 |
**Extension not capturing the code:** |
| 81 |
|
| 82 |
- Make sure Developer mode is enabled |
| 83 |
- Reload the extension |
| 84 |
- Check that the extension has the required permissions |
| 85 |
|
| 86 |
**Code not working:** |
| 87 |
|
| 88 |
- Authorization codes expire quickly (usually within 5 minutes) |
| 89 |
- Each code can only be used once |
| 90 |
- Make sure to use the code immediately after capture |
| 91 |
|
| 92 |
**Login page not loading:** |
| 93 |
|
| 94 |
- Clear browser cookies for duke-energy.com |
| 95 |
- Try an incognito window |
| 96 |
- Disable other extensions that might interfere |