Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to realize a login? #59

Closed
Muetze42 opened this issue Jun 28, 2020 · 4 comments
Closed

How to realize a login? #59

Muetze42 opened this issue Jun 28, 2020 · 4 comments
Labels

Comments

@Muetze42
Copy link

Muetze42 commented Jun 28, 2020

I plan to login via Twitch.

I have a login view.

    public function login()
    {
        return view('auth.login', [
            'authorize_url' => $this->twitch->getOAuthAuthorizeUrl($responseType = 'code')
        ]);
    }

I can get the code.

    public function callback(Request $request)
    {
        Log::info($request->code);
    }

But how do I get the information like email address, Twitch username & Twitch-ID from this user?

@romanzipp
Copy link
Owner

romanzipp commented Jun 29, 2020

You can obtain the OAuth Access & Refresh Token using the Twitch::getOAuthToken($code) method. The OAuth auth code flow is also documented on the Twitch Dev Docs page.

Although, I would recommend using Laravel Sociliate with the new Socialite Twitch Provider for handling OAuth.

@Muetze42
Copy link
Author

With this package and socialite the message: "invalid client secret" appears again and again. And this one is just like on Twitch. I've checked all the data a thousand times.

I don't know what's wrong with Twicht or what I should do about it.

@ghostzero
Copy link
Contributor

ghostzero commented Jul 8, 2020

This package (Laravel-Twitch) comes with the follwing env variables (which you must fill with your Twitch App information):

TWITCH_HELIX_KEY=
TWITCH_HELIX_SECRET=
TWITCH_HELIX_REDIRECT_URI=http://localhost

You have to change the following from the 4. Configuration setup tutorial to make the Twitch Socialite Provider compatible with Laravel-Twitch:

From:

'twitch' => [
    'client_id' => env('TWITCH_KEY'),
    'client_secret' => env('TWITCH_SECRET'),
    'redirect' => env('TWITCH_REDIRECT_URI')
],

To:

'twitch' => [
    'client_id' => env('TWITCH_HELIX_KEY'),
    'client_secret' => env('TWITCH_HELIX_SECRET'),
    'redirect' => env('TWITCH_REDIRECT_URI')
],

Thus the Twitch Socialite Provider uses the same credentials as for Laravel-Twitch.

@Muetze42
Copy link
Author

Muetze42 commented Jul 9, 2020

I had that first. Twitch keeps telling me that my client secret is wrong. Even with Postman. Other APIs (Facebook, Google, Steam etc) run without problems, just not theirs. I think their API just sucks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants