How to get the upwork client using php-upwork-oauth2
P粉627027031
P粉627027031 2024-03-30 00:41:19
0
1
379

I'm using the php-upwork-oauth2 package and symfony to get my upwork profile information.

Based on this repository: https://github.com/upwork/php-upwork-oauth2/blob/master/example/example.php I added my clientId and clientSecret:

$config = new \Upwork\API\Config([
        'clientId'          => '...', // SETUP YOUR CONSUMER KEY
        'clientSecret'      => '...', // SETUP KEY SECRET
        'redirectUri'       => 'https://localhost:8000/upwork',
        'accessToken'       => $session->get('access_token'),
        'accessSecret'      => $session->get('access_secret'),
        //'expiresIn'         => 'xxxxxxxxxx', // WARNING: keep this up-to-date!
        'debug'             => true, // enables debug mode
        //'authType'          => 'MyOAuthPHPLib' // your own authentication type, see AuthTypes directory
    ]);

    $client = new \Upwork\API\Client($config);

    $auth = new \Upwork\API\Routers\Auth($client);

    $info = $auth->getUserInfo();

    dd($info);

How to obtain accessToken and accessSecret?

I'm currently getting this error:

Call the member function getBody() on the string

P粉627027031
P粉627027031

reply all(1)
P粉696605833

What is $session->get('access_token'), in the code? Is something set? I recommend:

  1. Comment out the accessToken and accessSecret lines
  2. Follow the authentication and authorization process
  3. grep received access token/secret
  4. Add token pair to configuration
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!