I recently had a task come up where an existing system needed to allow its users to connect their YouTube account to their site account. Pretty simple task, really, when you get down to it.
- Use Oauth to allow YouTube to authenticate the connection
- Save said connection for later use
- ...
Yeah, no #3; easy peasy at first glance. But there was a complication.
- There were specific scopes needed (we needed permission to read their YouTube Comments)
- The site used an existing oauth library that, out of the box, didn't allow for all scopes we needed :(
For some reason (to be fair, I never did bother to ask the author the why of this...) but the library doesn't allow for the selection of the
https://www.googleapis.com/auth/youtube.force-ssl
Scope. And THAT scope is needed to read YouTube Comments, so little problem.
So, a Googlin' I went. To find fuck all about how to get around it. Which either meant I was an idiot and missing an obvious solution or I was the only person to ever have this issue with this library.
Jury's still out on the answer, but after 500 words of "where the fuck's he going with this", the solution was pretty simple.
- Create a Service object that extends the existing object
- Tell the library where to find the new object
The new service object
<?php
namespace Mithra62\Oauth\Services;
use OAuth\OAuth2\Service\Google AS GoogleService;
class Google extends GoogleService
{
const SCOPE_YOUTUBE_HTTPS = 'https://www.googleapis.com/auth/youtube.force-ssl';
}
Tell the library where to find the new object
<?php
use OAuth\ServiceFactory;
$service = new ServiceFactory();
$service->registerService('Google62', '\Mithra62\Oauth\Services\Google');
//continue oauth setup...
Congratulations @mithra62! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
You made your First Comment
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Why you don't just use hybridauth? This library has already everything you need: https://github.com/hybridauth/hybridauth
My tip: Use version 2, version 3 is still in beta.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @mithra62! You received a personal award!
Click here to view your Board
Do not miss the last post from @steemitboard:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @mithra62! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit