akeeba / sociallogin

Joomla!™ login and user account creation with Facebook, Google, GitHub etc social media accounts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration with Twitch

neo191987 opened this issue · comments

I managed to do it. I have one question how to get Client-Id in UserQuery.php file? Is there any developer documentation where I can see what does what?

There wouldn't be any kind of developer documentation for your UserQuery.php file because that's something you create yourself to fit the needs of the social network / service you are implementing :) In fact, having that file isn't even necessary; it's just a useful convention I applied to my now plugins because it helps me keep the code nicely organised.

I can, however, try to explain this as best as I can.

Whenever you have an object you instantiate that needs access to something the answer is almost always “injection”. The Client ID you need is a plugin parameter. The plugin parameters are made available to the plugin as a Joomla Registry object. UserQuery needs access to that Registry object. We can do that by passing this Registry object to the constructor of the UserQuery object and store that reference in a private property. This is the simplest form of constructor injection.

Start by creating the private property in UserQuery:

private \Joomla\Registry\Registry $params;

Then, modify UserQuery's constructor to take into account the Registry object:

public function __construct(?\Joomla\CMS\Http\Http $client = null, ?string $token = null, ?\Joomla\Registry\Registry $params)
{
  $this->client = $client;
  $this->token  = $token;
  $this->params = $params;
}

You instantiate your UserQuery class from your plugin's getSocialNetworkProfileInformation method. Change that instantiation so that it passes the Registry object with the plugin's configuration parameters as the third parameter to the constructor:

$userQuery  = new UserQuery($client, $accessToken, $this->params);

Now you can access all of your plugin's configuration parameters. Assuming you used the same conventions I did in my plugins for naming them:

$clientId = $this->params->get('appid');

Note that dependency injection, what I described, is the more pain the rear method for doing things — and the easiest to refactor when (not if!) the time comes. The alternative way is pulling the plugin parameters:

$clientId = (new \Joomla\Registry\Registry(
  \Joomla\CMS\Plugin\PluginHelper::getPlugin('sociallogin', 'myplugin')->params
))->get('appid');

This, too, works. However, any change in your plugin's name, or the way the PluginHelper works, or the Registry constructor and you're in for a bad time. Taking the concrete Registry object Joomla provides and passing it around is more robust (and allows for much easier unit testing, though in this particular use case I am not sure unit testing even makes sense).

Hi, I created a plugin for patreon but I get error 1020. As far as I understand it is caused by Cloudflare. Through Postman it works without a problem. Is there a way to avoid this?

If CloudFlare is on your own site, look at the last paragraph in https://www.howtogeek.com/853271/how-to-fix-error-1020-access-denied/. Basically, you can look up what caused the problem and fix it. Most likely something on your server (typically a mod_security2 rule in Apache you need to disable) causes a 403 error and CloudFlare reports it as error 1020.

On a final note, if you have made extra plugins you feel comfortable sharing, give me links and I can list them as third party plugins in the documentation and the README.

Hi, I haven't put protection under CloudFlare because I'm still developing it, as far as I've read it doesn't like User-Agent and Captcha is enabled and that's why it causes problems. About the plugins, of course I will share them, for now I only have one ready, and I want to make a few more for the more popular platforms.

https://www.patreondevelopers.com/t/getting-a-captcha-on-the-api-authorize-url/2795

Hi, I've made 4 working plugins and one that doesn't work, if you can test it when you're free - the non-working one is the one for paypal. I've removed the button colors and removed all comments in the code to make it easier for me to work with, so it's just clean code. Amazon and Spotify doesn't have a verified email option and I've set it to verified. Maybe there will be more new plugins soon.

https://github.com/neo191987/new-plugins

I have looked at all the providers and only these can work normally. The only ones I couldn't do were PayPal and Patreon - if you can add them in the future. I researched Twitter and it's been totally destroyed by Musk, so it's not doing anything anymore.

First of all, sorry for the late reply. There was a major change in WordPress which sucked most of my October and half of November. I was then playing catch-up with everything else that was left behind. I finally managed to circle back to this. I have good news, though!

I am happy to say that I made PayPal work :) Their documentation is a bit all over the place, but some trial and error helped. They are not exactly following the OAuth2 specification, and there is a delay between making changes to your OAuth2 app on their developer site and them being deployed live. I can see why you were frustrated. I'm kinda used to this kind of crap, so it was ultimately no biggie, just a couple of hours of my time.

If I have some spare time later today I will look into Patreon. You can expect a new release next week.

Thank you VERY MUCH for the plugins you contributed! I appreciate it very much, more than I can express with words. Thank you!