M
M
Mark2020-01-28 12:46:19
Yii
Mark, 2020-01-28 12:46:19

How to set the HTTPS protocol in the AuthChoice widget of the AuthClient extension from Yii2?

Situation: Using the AuthClient permission , there was a problem with the AuthChoice social button display widget .

Problem: AuthChoice generates a backlink for social networks with HTTP protocol, and Facebook requires HTTPS in recommend-force order.

To generate a URL, the widget takes the baseAuthUrl parameter , but you can set the relative path to the desired action as an array in it. Further, this data gets into Url::to() as the first parameter. But the second parameter of Url::to() , which is responsible for the protocol, is not allowed to be edited.

How to solve this problem? Perhaps I missed some parameter?

UPD:

Dug a little deeper. The problem is the same, but in a different place - \yii\authclient\BaseOAuth::defaultReturnUrl.
The returnURL is formed here, but just like in the widget, there is no way to set the protocol:

The code

kiss_15kb.1580220127.png


PS If you manually edit it in the vendor, insert "https" as the second parameter to createAbsoluteUrl() - everything works out and authorization passes.
I mean, it's definitely not about Facebook.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-01-28
@MarkLb

Alexander answered your question as follows:

BaseOAuth::defaultReturnUrl() doesn't specify protocol. It means return URL generated matches protocol used at the website. If your website is served via HTTP it doesn't make sense to set return URL to HTTPS.

You can read more about it here
. I totally agree with him. But if you need such a crutch, then here

D
dpws, 2020-01-28
@dpws

Generate it yourself: baseAuthUrl = Url::to['controller/action', 'https']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question