{"action":"created","issue":{"url":"https://api.github.com/repos/kaizensoze/node-github/issues/94","repository_url":"https://api.github.com/repos/kaizensoze/node-github","labels_url":"https://api.github.com/repos/kaizensoze/node-github/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/kaizensoze/node-github/issues/94/comments","events_url":"https://api.github.com/repos/kaizensoze/node-github/issues/94/events","html_url":"https://github.com/kaizensoze/node-github/issues/94","id":137366796,"number":94,"title":"Not Issue. Newbie Question on OAuth2 with GitHub","user":{"login":"lonniev","id":2193384,"avatar_url":"https://avatars.githubusercontent.com/u/2193384?v=3","gravatar_id":"","url":"https://api.github.com/users/lonniev","html_url":"https://github.com/lonniev","followers_url":"https://api.github.com/users/lonniev/followers","following_url":"https://api.github.com/users/lonniev/following{/other_user}","gists_url":"https://api.github.com/users/lonniev/gists{/gist_id}","starred_url":"https://api.github.com/users/lonniev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lonniev/subscriptions","organizations_url":"https://api.github.com/users/lonniev/orgs","repos_url":"https://api.github.com/users/lonniev/repos","events_url":"https://api.github.com/users/lonniev/events{/privacy}","received_events_url":"https://api.github.com/users/lonniev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-29T20:40:37Z","updated_at":"2016-03-01T02:13:58Z","closed_at":null,"body":"If I have a GitHub client app that it a chatbot and I want that chatbot to be able to modify GitHub content on behalf of the user in a chat room (e.g. \"bot create new github issue as @me\").\r\n\r\nThen I assume I need to have the chat room user be challenged for OAuth2 authentication when each user first asks the chatbot to a GitHub operation.\r\n\r\nThat is, the chatbot app doesn't need to authenticate with the GitHub API, it needs to get the current user's access token and pass that along in its request to the GitHub REST client.\r\n\r\nIs this correct?\r\n\r\nIf so, how does my nodejs client code either force the OAuth login process or retrieve the access token for a user who has already OAuth authenticated to the GitHub API.\r\n\r\nNow, because the IM service will be Gitter, is there already a Gitter API to get the current user's GitHub access token?"},"comment":{"url":"https://api.github.com/repos/kaizensoze/node-github/issues/comments/190496746","html_url":"https://github.com/kaizensoze/node-github/issues/94#issuecomment-190496746","issue_url":"https://api.github.com/repos/kaizensoze/node-github/issues/94","id":190496746,"user":{"login":"lonniev","id":2193384,"avatar_url":"https://avatars.githubusercontent.com/u/2193384?v=3","gravatar_id":"","url":"https://api.github.com/users/lonniev","html_url":"https://github.com/lonniev","followers_url":"https://api.github.com/users/lonniev/followers","following_url":"https://api.github.com/users/lonniev/following{/other_user}","gists_url":"https://api.github.com/users/lonniev/gists{/gist_id}","starred_url":"https://api.github.com/users/lonniev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lonniev/subscriptions","organizations_url":"https://api.github.com/users/lonniev/orgs","repos_url":"https://api.github.com/users/lonniev/repos","events_url":"https://api.github.com/users/lonniev/events{/privacy}","received_events_url":"https://api.github.com/users/lonniev/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T02:13:57Z","updated_at":"2016-03-01T02:13:57Z","body":"I think you are saying that the bot would interact with the user as follows:\n\nif the user already has asked the bot to do something for it in the recent past then there is context somewhere that has the access token. Find that and use it.\nif the user has not yet authorized the bot to act on its behalf, don’t do the requested operation but spit back the OAuth login URL to the chat room telling the user to click it if they want to delegate the bot. Somewhere save the resulting access token so that the check above succeeds.\n\n\n-- \nLonnie VanZandt\n303-900-3048\n\nOn 29 February 2016 at 14:36:29, Joe Gallo (notifications@github.com) wrote:\n\nUsually when you want to do a github action on behalf of a user you need to request permission via an app. If you go to your settings you can register a new application (https://github.com/settings/developers). You specify a callback url along with the desired permissions. Typically the user authorizes through the app with some sort of \"Login with Github\" button, but you could maybe have the bot post the direct authorize link that the user will click and then authorize the app (assuming they accept the requested permissions), triggering the callback url which will include the user's access token you'll need to store on the backend.\n\n—\nReply to this email directly or view it on GitHub.\n\n"}}