Today i will show to you how to use a OAuth 2 on Ebay, so how you can take your token, and then use it.

At first you must to register on https://developer.ebay.com

Then you must to set your Application on (Sandbox/Test or Production, in this guide i show to you Production procedure) https://developer.ebay.com/my/keys

After you must to have a situation like this:

Now we have:
– Client ID
– Dev ID
– Client Secret

We need:
– Authorization Code
– Access Token
– Refresh Token

Authorization Code

At first we must to generate the Authorization Code, and for this procedure we must to paste an url on the browser and copy the query string “code”.
So click on the “User token link”

Click on “Get a Token from eBay via Your Application”

Then you must to “Add eBay Redirect URL”
So you generate your app details, you can see the
“Your branded eBay Production Sign In (OAuth)” or if sandbox (test)
“Your branded eBay SandboxSign In (OAuth)”

Copy the link, that is like:

https://auth.ebay.com/oauth2/authorize?client_id=App-PRD-hhhhhf72-3hhb&response_type=code&redirect_uri=YourName-App–okllp&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly

Put this link on your browser, and login with your ebay account, so then you must to redirect on another page that sayd to you that the application has grant, and in the url bar you find your authorization code.

https://signin.ebay.com/ws/eBayISAPI.dll?ThirdPartyAuthSucessFailure&isAuthSuccessful=true&code=v%5K1.1HH%…..w&expires_in=299

Access Token and Refresh Token

Now with our authorization code, we call this url to take our access and refresh token.
For this call we need the authorization header, and create a base64 encode with clientID and certID.
And then in the parameter set Authorization code and RuName

$link = "https://api.ebay.com/identity/v1/oauth2/token";
        $codeAuth = base64_encode(':');
        $ch = curl_init($link);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic '.$codeAuth
        ));
        curl_setopt($ch, CURLHEADER_SEPARATE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=authorization_code&code==&redirect_uri=");
        $response = curl_exec($ch);
        $json = json_decode($response, true);
        $info = curl_getinfo($ch);
        curl_close($ch);
        if($json != null)
        {
            $this->authToken = $json["access_token"];
            $this->refreshToken = $json["refresh_token"];
        }

Why we have access token and refresh token?

We use Access Token for all the api request on eBay service.
We use Refresh Token to regenerate a Access Token.

Access token is valid 2 hour, but Refresh Token is valid 18 months.

How can i refresh my access token?

You must to take a call to this service, passing your refresh code, and the service return to you your new access token

$link = "https://api.ebay.com/identity/v1/oauth2/token";
        $codeAuth = base64_encode(':');
        $ch = curl_init($link);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic '.$codeAuth
        ));
        curl_setopt($ch, CURLHEADER_SEPARATE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=refresh_token&refresh_token&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly");
        $response = curl_exec($ch);
        $json = json_decode($response, true);
        $info = curl_getinfo($ch);
        curl_close($ch);
        if($json != null)
        {
            $this->authToken = $json["access_token"];
        }

I suggest to save your Access Token and Refresh Token on Database.

At the end my eBay API Simple Class

<?php

class EbayAPI
{
    protected $devID;
    protected $appID;
    protected $certID;
    protected $clientID;
    protected $serverUrl;
    public $userToken;
    protected $paypalEmailAddress;
    protected $ruName;


    public function __construct()
    {
        $this->devID = '<your-dev-id>'; // these prod keys are different from sandbox keys
        $this->appID = '<your-app-id>';
        $this->certID = '<your-cert-id>';
        $this->clientID = '<your-client-id>';
        //set the Server to use (Sandbox or Production)
        $this->serverUrl = 'https://api.ebay.com/ws/api.dll';      // server URL different for prod and sandbox
        //the token representing the eBay user to assign the call with

        $this->authCode = '<paste here your authorization code>'; 
        $this->authToken ="";
        $this->refreshToken ="";
        $this->ruName= "";

        $this->paypalEmailAddress= 'PAYPAL_EMAIL_ADDRESS';
        
    }

    public function firstAuthAppToken() {
        $url = "https://auth.ebay.com/oauth2/authorize?client_id=".$this->clientID."&response_type=code&redirect_uri=".$this->ruName."&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly"; 
return $url;      
    }

    public function authorizationToken()
    {
        $link = "https://api.ebay.com/identity/v1/oauth2/token";
        $codeAuth = base64_encode($this->clientID.':'.$this->certID);
        $ch = curl_init($link);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic '.$codeAuth
        ));
        curl_setopt($ch, CURLHEADER_SEPARATE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=authorization_code&code=".$this->authCode."&redirect_uri=".$this->ruName);
        $response = curl_exec($ch);
        $json = json_decode($response, true);
        $info = curl_getinfo($ch);
        curl_close($ch);
        if($json != null)
        {
            $this->authToken = $json["access_token"];
            $this->refreshToken = $json["refresh_token"]; 
        } 
    }

    public function refreshToken()
    {
        $link = "https://api.ebay.com/identity/v1/oauth2/token";
        $codeAuth = base64_encode($this->clientID.':'.$this->certID);
        $ch = curl_init($link);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic '.$codeAuth
        ));
        echo $this->refreshToken;
        curl_setopt($ch, CURLHEADER_SEPARATE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=refresh_token&refresh_token=".$this->refreshToken."&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly");
        $response = curl_exec($ch);
        $json = json_decode($response, true);
        $info = curl_getinfo($ch);
        curl_close($ch);
        if($json != null)
        {
            $this->authToken = $json["access_token"];
        } 
    }
}

27 Comments

  1. I have changed “&amp” to “&” in CURLOPT_POSTFIELDS, add PHP function “urlencode” before all POST data (for example:
    urlencode($this->authCode)
    scope=”.urlencode(“https…
    )
    and now works perfect.

  2. @Piotr yes sorry the code editor change some html char. For the urlencode i don’t use it and work. Thank you for the suggest!

  3. Thanks for reply. But i want to know that’s when this method to be call. Method name – ” firstAuthAppToken()”

    public function firstAuthAppToken() {
    $url = “https://auth.ebay.com/oauth2/authorize?client_id=”.$this->clientID.”&response_type=code&redirect_uri=”.$this->ruName.”&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly“;
    }

  4. Okay i have understand.
    In the function you must to add:

    public function firstAuthAppToken() {
    $url = “https://auth.ebay.com/oauth2/authorize?client_id=”.$this->clientID.”&response_type=code&redirect_uri=”.$this->ruName.”&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly“;
    return $url;
    }

    You can create a php file, in witch you can call this function, so this function generate to you an url, you must to copy and paste this in the url bar of your browser, and then when redirect you back, in the url you can see the auth token, that you must to copy and paste in you database.
    Or you can simply generate a php redict page, that take a $_GET token param and save it in you database.

  5. This is a stupid question sorry!

    I have got to the point where I have my authorisation code

    Where do I run the curl request from? And where should the authorisation code and ruName go?

    Thanks!

  6. SUPER IMPORTANT:

    in case u want to call “old apis” (like shopping API) via OAuth, this whole blog entry does not work for you, because you DONT need a “user access token”, you need an “application access token” – a total different thing 😉

    https://developer.ebay.com/api-docs/static/oauth-token-types.html

    read here how to get one:

    https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html

    the “application access token” is NOT connected to a user’s Ebay account and has NO refresh token.

  7. @Anne the ruName is the “Ebay redirect url name” like in the screenshot “Lenny_Rice_Book-LennyRic-“, and you must to insert that string.

  8. Need assistance in switching eBay Shopping API to OAuth authorization in our php application.

    We are looking for somebody with experience to help us in converting ebay shopping API to use oauth application access token
    I need step by step guide on how to change the APPID based calls to Oauth.

    Here is actual code (using the shopping API call) from our php application:

    function eBay_API($app, $data, $api_type = 0, $sandbox = 0)
    {
    // using shopping api
    if ($api_type == 1)
    {
    $header = array(
    ‘X-EBAY-API-VERSION:829’,
    ‘X-EBAY-API-APP-ID:APP_ID_HERE’,
    ‘X-EBAY-API-CALL-NAME:’.$app,
    ‘X-EBAY-API-REQUEST-ENCODING:XML’,
    ‘X-EBAY-API-SITE-ID:0’,
    ‘Content-Type: text/xml;charset=utf-8’,
    );
    if ($sandbox)
    $api_url = “http://open.api.sandbox.ebay.com/shopping?”;
    else
    $api_url = “http://open.api.ebay.com/shopping?”;
    }
    // using trading api
    else
    {
    $header = array(
    ‘X-EBAY-API-COMPATIBILITY-LEVEL:811’,
    ‘X-EBAY-API-DEV-NAME:DEV_NAME’,
    ‘X-EBAY-API-APP-NAME:APP_NAME’,
    ‘X-EBAY-API-CERT-NAME:CERT_NAME’,
    ‘X-EBAY-API-CALL-NAME:’.$app,
    ‘X-EBAY-API-SITEID:0’,
    );
    if ($sandbox)
    $api_url = “https://api.sandbox.ebay.com/ws/api.dll”;
    else
    $api_url = “https://api.ebay.com/ws/api.dll”;
    }

    $ch = curl_init($api_url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);

    return $output;
    }

    thanks
    Yasir
    yasir.ikram@greencitizen.com

  9. Wow, what a great lesson. But, tutor how can i get application access token for shopping api.Please any help wll be grateful. Thanks very much.please share a link if you have any tutorial on that.

  10. Please that is my code that i copy and used. But it is not working. i do get the response “This site can’t be reachedlocalhost refused to connect.
    Try:

    Checking the connection
    Checking the proxy and the firewall
    ERR_CONNECTION_REFUSED”

    What I my missing. Any answer wll be grately be appreciated. Thanks.

    devID = ‘e87b5af6-d1a2-463b-a522-128d4c884282’; // these prod keys are different from sandbox keys
    $this->appID = ‘beltamon-belta-PRD-31a11534d-138e8be6’;
    $this->certID = ‘PRD-1a11534d7711-39da-4274-ac8d-5a06’;
    $this->clientID = ”;
    //set the Server to use (Sandbox or Production)
    $this->serverUrl = ‘https://api.ebay.com/ws/api.dll’; // server URL different for prod and sandbox
    //the token representing the eBay user to assign the call with

    $this->authCode = ‘https://signin.ebay.com/ws/eBayISAPI.dll?ThirdPartyAuthSucessFailure&isAuthSuccessful=true&code=v%5E1.1%23i%5E1%23r%5E1%23p%5E3%23I%5E3%23f%5E0%23t%5EUl41XzQ6Qjg4RTYzMUVCN0EyRDFGN0RGOEJEQTU1RDZBMURCNkJfMF8xI0VeMjYw&expires_in=299’;
    $this->authToken =””;
    $this->refreshToken =””;
    $this->ruName= “belta_monic-beltamon-belta–ixtnzo”;

    $this->paypalEmailAddress= ”;

    }

    public function firstAuthAppToken() {
    $url = “https://auth.ebay.com/oauth2/authorize?client_id=”.$this->clientID.”&response_type=code&redirect_uri=”.$this->ruName.”&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly“;
    return $url;
    }

    public function authorizationToken()
    {
    $link = “https://api.ebay.com/identity/v1/oauth2/token”;
    $codeAuth = base64_encode($this->clientID.’:’.$this->certID);
    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    ‘Content-Type: application/x-www-form-urlencoded’,
    ‘Authorization: Basic ‘.$codeAuth
    ));
    curl_setopt($ch, CURLHEADER_SEPARATE, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, “grant_type=authorization_code&code=”.$this->authCode.”&redirect_uri=”.$this->ruName);
    $response = curl_exec($ch);
    $json = json_decode($response, true);
    $info = curl_getinfo($ch);
    curl_close($ch);
    if($json != null)
    {
    $this->authToken = $json[“access_token”];
    $this->refreshToken = $json[“refresh_token”];
    }
    }

    public function refreshToken()
    {
    $link = “https://api.ebay.com/identity/v1/oauth2/token”;
    $codeAuth = base64_encode($this->clientID.’:’.$this->certID);
    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    ‘Content-Type: application/x-www-form-urlencoded’,
    ‘Authorization: Basic ‘.$codeAuth
    ));
    echo $this->refreshToken;
    curl_setopt($ch, CURLHEADER_SEPARATE, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, “grant_type=refresh_token&refresh_token=”.$this->refreshToken.”&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly“);
    $response = curl_exec($ch);
    $json = json_decode($response, true);
    $info = curl_getinfo($ch);
    curl_close($ch);
    if($json != null)
    {
    $gg = $this->authToken = $json[“access_token”];
    echo $gg;
    }
    }
    }

    ?>

  11. Is it possible to use above class in REST API to connect eBay ?
    I am getting below response

    jSON response
    (
    [error] => invalid_client
    [error_description] => client authentication failed
    )

  12. Hi Francesco !
    Very helpfull post.
    Just a question:
    How I can use this function
    public function firstAuthAppToken() {
    $url = “https://auth.ebay.com/oauth2/authorize?client_id=”.$this->clientID.”&response_type=code&redirect_uri=”.$this->ruName.”&scope=https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/sell.marketing.readonly https://api.ebay.com/oauth/api_scope/sell.marketing https://api.ebay.com/oauth/api_scope/sell.inventory.readonly https://api.ebay.com/oauth/api_scope/sell.inventory https://api.ebay.com/oauth/api_scope/sell.account.readonly https://api.ebay.com/oauth/api_scope/sell.account https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly https://api.ebay.com/oauth/api_scope/sell.fulfillment https://api.ebay.com/oauth/api_scope/sell.analytics.readonly“;
    return $url;
    }

    for automate the creation of the authorization code every 18 months ?
    I have tried with file_get_contents() urlencoding the scope contents (due to spaces) without success

  13. Hi, Great detailed post but I think I must be missing a key element. I have created my php script with your “At the end my eBay API Simple Class” and changed all of values required for my ebay account but I am not getting any token returned nor any errors!
    Is it a simple case of making a php file and pasting the code into it or do I need to have some code to trigger the functions?

    Thanks for any guidance provided.

  14. I have some response (I guess some parameters are wrong or missing):
    array(2) {
    [“error”]=>
    string(13) “invalid_grant”
    [“error_description”]=>
    string(80) “the provided authorization grant code is invalid or was issued to another client”
    }
    array(2) {
    [“error”]=>
    string(14) “invalid_client”
    [“error_description”]=>
    string(28) “client authentication failed”
    }
    array(2) {
    [“error”]=>
    string(22) “unsupported_grant_type”
    [“error_description”]=>
    string(66) “grant type in request is not supported by the authorization server”
    }

  15. Please help me to fix the invalid scope issue in eBay OAuth Token Using Refresh Token API. I am in production Mode. Even not the primary scope https://api.ebay.com/oauth/api_scope is working for me. I am using PHP.

    $curlSecondHandler = curl_init();

    curl_setopt_array($curlSecondHandler, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => “grant_type=refresh_token&refresh_token=”.$refreshToken.”&scope=”.urlencode($scopes),
    CURLOPT_HTTPHEADER => [
    ‘Content-Type: application/x-www-form-urlencoded’,
    ‘Authorization: Basic ‘ . base64_encode($clientId . ‘:’ . $certId)
    ],
    ]);

  16. Hello.
    I followed the simple instructions provided, created an auth code and copied from the url (including the code=? (I tried with and without just in case, seemed like an error to me).
    For $response I get “the provided authorization grant code is invalid or was issued to another client”

    Any idea what’s wrong? these are the fields I filled, did I miss anything?

    $this->devID = ‘aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee’;
    $this->appID = ‘MyName-1111-2222-3333-444444444444’;
    $this->certID = ‘aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee’;
    $this->clientID = ‘MyName-1111-2222-3333-444444444444’; // The same as devID?!?!
    //set the Server to use (Sandbox or Production)
    $this->serverUrl = ‘https://api.ebay.com/ws/api.dll’; // server URL different for prod and sandbox
    //the token representing the eBay user to assign the call with

    $this->authCode = ‘code=v%5E1.1……………………………………………………………………………………………….Ab’;
    $this->authToken =””;
    $this->refreshToken =””;
    $this->ruName= “My_Name-MyName-11a1-1-abcdefg”;

    $this->paypalEmailAddress= ‘my@email.com’;

    Thanks!

  17. Hi, when i make the request:
    authorizationToken()

    response is bool(false),

    can someOne help me?

  18. Hi Denis,
    yes it’s correct because set the 2 variable:

    if($json != null)
    {
    $this->authToken = $json[“access_token”];
    $this->refreshToken = $json[“refresh_token”];
    }

    if you want you can put a return $this;

Leave a Reply

Your email address will not be published.