Skip to content

Problem during the callback #3

@Niji-Bemani

Description

@Niji-Bemani

Hi,
I tried to use this package, but I have some troubles to make it work.

Firstly, I got the same issue discussed in this pull request. So, I used this fix and I could get the authorization url from Etsy. (thanks to Joe Dawson!)

For the next, I don't know is the good way to do, but I made a redirection to this authorization url to be able to click on the button to allow access to my app.

Then, I'm getting the following error during the callback :

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Argument 1 passed to League\OAuth1\Client\Server\Server::getTokenCredentials() must be an instance of League\OAuth1\Client\Credentials\TemporaryCredentials, boolean given, called in /vendor/gentor/etsy-php-laravel/src/EtsyService.php on line 79

Actually, when I check the approve function in EtsyService.php, I can find unserialize($this->session->get('temporary_credentials')); returns false

public function approve($token, $verifier)
    {
        // Retrieve the temporary credentials we saved before
        $temporaryCredentials = unserialize($this->session->get('temporary_credentials'));

        return $this->server->getTokenCredentials($temporaryCredentials, $token, $verifier);
    }

This is my controller :

<?php

namespace App\Http\Controllers;

use Gentor\Etsy\Facades\Etsy;
use Illuminate\Http\Request;

class EtsyController extends Controller
{
    public function index()
    {
        // The $callbackUrl is the url of your app where Etsy sends the data needed for getting token credentials
        $callbackUrl = 'http://127.0.0.1:8001/etsy/callback';

        // The $authorizationUrl is the Etsy url where the user approves your app
        $authorizationUrl = Etsy::authorize($callbackUrl);

        return redirect($authorizationUrl);
    }

    public function store(Request $request)
    {
        // On the callback endpoint run this code to get the token credentials and add them to your config
        $tokenCredentials = Etsy::approve($request->get('oauth_token'), $request->get('oauth_verifier'));

        $tokens = [
            'access_token' => $tokenCredentials->getIdentifier(),
            'access_token_secret' => $tokenCredentials->getSecret(),
        ];

        dd($tokens);
    }
}

It seems that is a session problem, maybe I should not make a redirection, but I don't know what else to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions