{"action":"created","issue":{"url":"https://api.github.com/repos/Franklin89/NGitLab/issues/37","repository_url":"https://api.github.com/repos/Franklin89/NGitLab","labels_url":"https://api.github.com/repos/Franklin89/NGitLab/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/Franklin89/NGitLab/issues/37/comments","events_url":"https://api.github.com/repos/Franklin89/NGitLab/issues/37/events","html_url":"https://github.com/Franklin89/NGitLab/issues/37","id":145015472,"number":37,"title":"obtain token through api","user":{"login":"omkelderman","id":2544736,"avatar_url":"https://avatars.githubusercontent.com/u/2544736?v=3","gravatar_id":"","url":"https://api.github.com/users/omkelderman","html_url":"https://github.com/omkelderman","followers_url":"https://api.github.com/users/omkelderman/followers","following_url":"https://api.github.com/users/omkelderman/following{/other_user}","gists_url":"https://api.github.com/users/omkelderman/gists{/gist_id}","starred_url":"https://api.github.com/users/omkelderman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omkelderman/subscriptions","organizations_url":"https://api.github.com/users/omkelderman/orgs","repos_url":"https://api.github.com/users/omkelderman/repos","events_url":"https://api.github.com/users/omkelderman/events{/privacy}","received_events_url":"https://api.github.com/users/omkelderman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Franklin89/NGitLab/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-03-31T20:53:40Z","updated_at":"2016-09-08T17:26:43Z","closed_at":null,"body":"I would like to obtain the private token as per http://doc.gitlab.com/ce/api/session.html, so users of my application don't have to look up their token if they don't want to (and with \"users\", I mean primarily myself :stuck_out_tongue:)\r\n\r\nAs proof of concept I did this:\r\n```c#\r\nAPI gitlabApi = new API(\"...\", null);\r\nSession x = gitlabApi.Post().With(new IHaveNoIdeaHowToNameThis()\r\n{\r\n    Login = \"***\", // can also be Email = \"***\"\r\n    Password = \"***\"\r\n}).To<Session>(\"/session\");\r\nMessageBox.Show(x.PrivateToken);\r\n```\r\n\r\nWhere `IHaveNoIdeaHowToNameThis` is:\r\n```c#\r\nclass IHaveNoIdeaHowToNameThis\r\n{\r\n    [DataMember(Name = \"login\")]\r\n    public string Login;\r\n    [DataMember(Name = \"email\")]\r\n    public string Email;\r\n    [DataMember(Name = \"password\")]\r\n    public string Password;\r\n}\r\n```\r\nThis works perfectly fine and I get my api-token.\r\n\r\nI would be happy to provide a pull request, but I'm not sure how you would want this implemented.\r\n\r\nI was thinking about an additional public static method in `GitLabClient` called something like `GetSession` (since it returns a Session object), or maybe just something like `Login`... (After this, you would be able to use the obtained api-token on `GitLabClient.Connect` and proceed as normal.)\r\nI also don't know how to call the `IHaveNoIdeaHowToNameThis` class and where to put it (although I'm guessing in `NGitLab.Models`."},"comment":{"url":"https://api.github.com/repos/Franklin89/NGitLab/issues/comments/245673858","html_url":"https://github.com/Franklin89/NGitLab/issues/37#issuecomment-245673858","issue_url":"https://api.github.com/repos/Franklin89/NGitLab/issues/37","id":245673858,"user":{"login":"Franklin89","id":4151467,"avatar_url":"https://avatars.githubusercontent.com/u/4151467?v=3","gravatar_id":"","url":"https://api.github.com/users/Franklin89","html_url":"https://github.com/Franklin89","followers_url":"https://api.github.com/users/Franklin89/followers","following_url":"https://api.github.com/users/Franklin89/following{/other_user}","gists_url":"https://api.github.com/users/Franklin89/gists{/gist_id}","starred_url":"https://api.github.com/users/Franklin89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Franklin89/subscriptions","organizations_url":"https://api.github.com/users/Franklin89/orgs","repos_url":"https://api.github.com/users/Franklin89/repos","events_url":"https://api.github.com/users/Franklin89/events{/privacy}","received_events_url":"https://api.github.com/users/Franklin89/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T17:26:43Z","updated_at":"2016-09-08T17:26:43Z","body":"This is interesting and my it I think I will look into this as soon as i finish getting all the unit test to run on appveyor and added some integration tests with a gitlab server.\r\n\r\nI believe it would be interesting to add all the different approaches to authenticate with Gitlab:\r\n\r\n**Private Tokens**\r\n**OAuth 2 Tokens**\r\n**Personal Access Tokens**"}}
{"actor":{"display_login":"Franklin89"}}