{"id":17723372,"url":"https://github.com/aaronpk/device-flow-proxy-server","last_synced_at":"2025-05-05T21:36:06.361Z","repository":{"id":53852051,"uuid":"46383623","full_name":"aaronpk/Device-Flow-Proxy-Server","owner":"aaronpk","description":"Add the OAuth 2.0 Device Flow to any OAuth server","archived":false,"fork":false,"pushed_at":"2020-06-13T20:31:55.000Z","size":180,"stargazers_count":70,"open_issues_count":1,"forks_count":30,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-04-12T19:53:03.547Z","etag":null,"topics":["device-flow","oauth","oauth2"],"latest_commit_sha":null,"homepage":"https://developer.okta.com/blog/2019/02/19/add-oauth-device-flow-to-any-server","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aaronpk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-18T00:05:33.000Z","updated_at":"2024-03-13T22:26:18.000Z","dependencies_parsed_at":"2022-08-23T13:41:37.491Z","dependency_job_id":null,"html_url":"https://github.com/aaronpk/Device-Flow-Proxy-Server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronpk%2FDevice-Flow-Proxy-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronpk%2FDevice-Flow-Proxy-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronpk%2FDevice-Flow-Proxy-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronpk%2FDevice-Flow-Proxy-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aaronpk","download_url":"https://codeload.github.com/aaronpk/Device-Flow-Proxy-Server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252580724,"owners_count":21771381,"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":["device-flow","oauth","oauth2"],"created_at":"2024-10-25T15:42:45.934Z","updated_at":"2025-05-05T21:36:06.344Z","avatar_url":"https://github.com/aaronpk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"OAuth 2.0 Device Flow Proxy Server\n==================================\n\nA demonstration of the OAuth 2.0 Device Code flow for devices without a browser or with limited keyboard entry.\n\nThis service acts as an OAuth server that implements the device code flow, proxying to a real OAuth server behind the scenes.\n\nInstallation\n------------\n\n```\ncomposer install\ncp .env.example .env\n```\n\nIn the `.env` file, fill out the required variables.\n\nYou will need to install Redis if it is not already on your system, or point to an existing redis server in the config file.\n\nDefine your OAuth server's authorization endpoint and token endpoint URL.\n\n### Heroku Deploy\n\nTo deploy this in Heroku, you'll need to do the following:\n\nCreate a new Heroku application, and take note of the name.\n\nDefine environment variables in Heroku's admin interface based on the values from `.env.example` with the exception of `REDIS_URL`.\n\n![Heroku Config](heroku-env.png)\n\n```\n# Log in to your Heroku account\nheroku login\n\n# Define the Heroku upstream git repo from your app name\nheroku git:remote -a oauth-device-flow-demo\n\n# Enable Redis for your application\nheroku addons:create heroku-redis:hobby-dev\n\n# Deploy to Heroku\ngit push heroku master\n```\n\n\nUsage\n-----\n\nThe device will need to register an application at the OAuth server to get a client ID. You'll need to set the proxy's URL as the callback URL in the OAuth application registration:\n\n```\nhttp://localhost:8080/auth/redirect\n```\n\nThe device can begin the flow by making a POST request to this proxy:\n\n```\ncurl http://localhost:8080/device/code -d client_id=1234567890\n```\n\nThe response will contain the URL the user should visit and the code they should enter, as well as a long device code.\n\n```json\n{\n    \"device_code\": \"5cb3a6029c967a7b04f642a5b92b5cca237ec19d41853f55dcce98a4d2aa528f\",\n    \"user_code\": \"248707\",\n    \"verification_uri\": \"http://localhost:8080/device\",\n    \"expires_in\": 300,\n    \"interval\": 5\n}\n```\n\nThe device should instruct the user to visit the URL and enter the code, or can provide a full link that pre-fills the code for the user in case the device is displaying a QR code.\n\n`http://localhost:8080/device?code=248707`\n\nThe device should then poll the token endpoint at the interval provided, making a POST request like the below:\n\n```\ncurl http://localhost:8080/device/token -d grant_type=urn:ietf:params:oauth:grant-type:device_code \\\n  -d client_id=1234567890 \\\n  -d device_code=5cb3a6029c967a7b04f642a5b92b5cca237ec19d41853f55dcce98a4d2aa528f\n```\n\nWhile the user is busy logging in, the response will be\n\n```\n{\"error\":\"authorization_pending\"}\n```\n\nOnce the user has finished logging in and granting access to the application, the response will contain an access token.\n\n```json\n{\n  \"access_token\": \"FmcTZiYmJzeWpoeTdUSTBoNyIsInVpZCI6IjAwdWJ1NG1\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 7200\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronpk%2Fdevice-flow-proxy-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronpk%2Fdevice-flow-proxy-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronpk%2Fdevice-flow-proxy-server/lists"}