{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/268","labels_url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/268/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/268/comments","events_url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/268/events","html_url":"https://github.com/thephpleague/oauth2-client/issues/268","id":69964300,"number":268,"title":"[RFC] ProviderInterface::getAuthenticatedRequest() method","user":{"login":"ramsey","id":42941,"avatar_url":"https://avatars.githubusercontent.com/u/42941?v=3","gravatar_id":"","url":"https://api.github.com/users/ramsey","html_url":"https://github.com/ramsey","followers_url":"https://api.github.com/users/ramsey/followers","following_url":"https://api.github.com/users/ramsey/following{/other_user}","gists_url":"https://api.github.com/users/ramsey/gists{/gist_id}","starred_url":"https://api.github.com/users/ramsey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramsey/subscriptions","organizations_url":"https://api.github.com/users/ramsey/orgs","repos_url":"https://api.github.com/users/ramsey/repos","events_url":"https://api.github.com/users/ramsey/events{/privacy}","received_events_url":"https://api.github.com/users/ramsey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/thephpleague/oauth2-client/milestones/1","html_url":"https://github.com/thephpleague/oauth2-client/milestones/v1.0","labels_url":"https://api.github.com/repos/thephpleague/oauth2-client/milestones/1/labels","id":724139,"number":1,"title":"v1.0","description":"","creator":{"login":"alexbilbie","id":77991,"avatar_url":"https://avatars.githubusercontent.com/u/77991?v=3","gravatar_id":"","url":"https://api.github.com/users/alexbilbie","html_url":"https://github.com/alexbilbie","followers_url":"https://api.github.com/users/alexbilbie/followers","following_url":"https://api.github.com/users/alexbilbie/following{/other_user}","gists_url":"https://api.github.com/users/alexbilbie/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbilbie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbilbie/subscriptions","organizations_url":"https://api.github.com/users/alexbilbie/orgs","repos_url":"https://api.github.com/users/alexbilbie/repos","events_url":"https://api.github.com/users/alexbilbie/events{/privacy}","received_events_url":"https://api.github.com/users/alexbilbie/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":8,"state":"open","created_at":"2014-07-17T11:46:55Z","updated_at":"2015-04-21T22:08:58Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2015-04-21T22:08:46Z","updated_at":"2015-04-21T23:35:36Z","closed_at":null,"body":"This would give users of Providers a method that returns an already-authenticated HTTP client, using the token retrieved in the OAuth 2.0 flow. They may then use this client object to make authenticated requests of whatever provider API they are using, without the OAuth 2.0 Provider classes becoming API wrappers.\r\n\r\nFrom @shadowhand in the comments on https://github.com/thephpleague/oauth2-client/issues/265#issuecomment-94943566:\r\n\r\n> One of the things that always bothered me about this library (and am moving towards solving with #232) is that it doesn't do very much to make **using** the provider APIs easier, it only gets us to the point of having an authenticated token.\r\n> \r\n> I'll be very clear here and say that **the goal is not to create API wrappers** with providers. However, I think a very valuable part of this package is that it makes it **easier to use provider APIs** and so any changes we are proposing here should keep that in mind.\r\n> \r\n> To this end, what are valuable things this package can do to make API usage easier?\r\n> \r\n> 1. Ensure that providers contain a method to fetch an API base URL. This is not very useful by itself, but it makes writing multiple API calls much DRYer.\r\n> 2. Ensure that providers contain a method to add authentication to a request. This is what #232 did (see also thephpleague/oauth1-client#18) and it immediately improved the code I was working on that made API calls.\r\n> 3. Provide ways to integrate more cleanly with dependent packages. The client already uses Guzzle, so it should expose methods that work with those classes. For instance, having a method like this would save a lot of repeated code:\r\n> \r\n> ```php\r\n> /**\r\n>  * Create an authenticated client to access an API URL.\r\n>  *\r\n>  * @param  string $method\r\n>  * @param  string $path\r\n>  * @param  AccessToken $token\r\n>  * @return Psr\\Http\\Message\\RequestInterface\r\n>  */\r\n> public function getAuthenticatedRequest($method, $path, AccessToken $token);\r\n> ```\r\n> \r\n> This would allow us to write code like:\r\n> \r\n> ```php\r\n> $request = $client->getAuthenticatedRequest('GET', 'me?fields=id,name,email', $token);\r\n> $response = $client->send($request);\r\n> $me = json_decode($response->getBody());\r\n> ```\r\n> \r\n> Personally I would find this to be a *very* useful and complete example of how to build upon what the package provides and represents best practice."},"comment":{"url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/comments/94974780","html_url":"https://github.com/thephpleague/oauth2-client/issues/268#issuecomment-94974780","issue_url":"https://api.github.com/repos/thephpleague/oauth2-client/issues/268","id":94974780,"user":{"login":"ramsey","id":42941,"avatar_url":"https://avatars.githubusercontent.com/u/42941?v=3","gravatar_id":"","url":"https://api.github.com/users/ramsey","html_url":"https://github.com/ramsey","followers_url":"https://api.github.com/users/ramsey/followers","following_url":"https://api.github.com/users/ramsey/following{/other_user}","gists_url":"https://api.github.com/users/ramsey/gists{/gist_id}","starred_url":"https://api.github.com/users/ramsey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramsey/subscriptions","organizations_url":"https://api.github.com/users/ramsey/orgs","repos_url":"https://api.github.com/users/ramsey/repos","events_url":"https://api.github.com/users/ramsey/events{/privacy}","received_events_url":"https://api.github.com/users/ramsey/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T23:35:36Z","updated_at":"2015-04-21T23:35:36Z","body":"Oops! I've edited the example and removed it. :-)"}}