1

I am trying to integrate Zoom with my CodeIgneter application using API with OAuth method. I created an Access Token and integrated my Zoom account with my application successfully. After 1 hr the Zoom account access key expired. In the Zoom API document it says that after 1 hr the access token will expire and after that we can generate an access token using Refresh Token.

Used Document: OAuth Document:-

I am creating a function to create an access token after expired by using the refresh token.

My Code is:

$clients = new GuzzleHttp\Client(['base_uri' => 'https://zoom.us']);
$arr_tokens = $this->get_access_token();    
$refresh_tokens = $arr_tokens->refresh_token;
$response = $clients->request('POST', '/oauth/token', [
    "headers" => [
        "Authorization" => "Basic Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=". base64_encode(CLIENT_ID.':'.CLIENT_SECRET)
    ],
    'form_params' => [
        "grant_type" => "refresh_token",
        "refresh_token" => $refresh_tokens
    ],
]);

Here $refresh_tokens have my refresh token.CLIENT_ID and CLIENT_SECRET are my client id and client secret key. I am trying this code and printed the response. But the response is not similar to what I expected. There is no access token or refresh token.

Expected response:

{
"access_token": "eyJhbGciOiJIUzUxMiIsInYiOiIyLjAiLCJraWQiOiI8S0lEPiJ9.eyJ2ZXIiOiI2IiwiY2xpZW50SWQiOiI8Q2xpZW50X0lEPiIsImNvZGUiOiI8Q29kZT4iLCJpc3MiOiJ1cm46em9vbTpjb25uZWN0OmNsaWVudGlkOjxDbGllbnRfSUQ-IiwiYXV0aGVudGljYXRpb25JZCI6IjxBdXRoZW50aWNhdGlvbl9JRD4iLCJ1c2VySWQiOiI8VXNlcl9JRD4iLCJncm91cE51bWJlciI6MCwiYXVkIjoiaHR0cHM6Ly9vYXV0aC56b29tLnVzIiwiYWNjb3VudElkIjoiPEFjY291bnRfSUQ-IiwibmJmIjoxNTgwMTQ3Mzk0LCJleHAiOjE1ODAxNTA5OTQsInRva2VuVHlwZSI6ImFjY2Vzc190b2tlbiIsImlhdCI6MTU4MDE0NzM5NCwianRpIjoiPEpUST4iLCJ0b2xlcmFuY2VJZCI6MjZ9.5c58p0PflZJdlz4Y7PgMIVCrQpHDnbM565iCKlrtajZ5HHmy00P5FCcoMwHb9LxjsUgbJ7653EfdeX5NEm6RoA",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzUxMiIsInYiOiIyLjAiLCJraWQiOiI8S0lEPiJ9.eyJ2ZXIiOiI2IiwiY2xpZW50SWQiOiI8Q2xpZW50X0lEPiIsImNvZGUiOiI8Q29kZT4iLCJpc3MiOiJ1cm46em9vbTpjb25uZWN0OmNsaWVudGlkOjxDbGllbnRfSUQ-IiwiYXV0aGVudGljYXRpb25JZCI6IjxBdXRoZW50aWNhdGlvbl9JRD4iLCJ1c2VySWQiOiI8VXNlcl9JRD4iLCJncm91cE51bWJlciI6MCwiYXVkIjoiaHR0cHM6Ly9vYXV0aC56b29tLnVzIiwiYWNjb3VudElkIjoiPEFjY291bnRfSUQ-IiwibmJmIjoxNTgwMTQ3Mzk0LCJleHAiOjIwNTMxODczOTQsInRva2VuVHlwZSI6InJlZnJlc2hfdG9rZW4iLCJpYXQiOjE1ODAxNDczOTQsImp0aSI6IjxKVEk-IiwidG9sZXJhbmNlSWQiOjI2fQ.DwuqOzywRrQO2a6yp0K_6V-hR_i_mOB62flkr0_NfFdYsSqahIRRGk1GlUTQnFzHd896XDKf_FnSSvoJg_tzuQ",
"expires_in": 3599,
"scope": "user:read" }

Actual Response:

GuzzleHttp\Psr7\Response Object
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => OK
[statusCode:GuzzleHttp\Psr7\Response:private] => 200
[headers:GuzzleHttp\Psr7\Response:private] => Array
    (
        [Date] => Array
            (
                [0] => Thu, 03 Sep 2020 12:58:09 GMT
            )

        [Content-Type] => Array
            (
                [0] => text/html;charset=utf-8
            )

        [Transfer-Encoding] => Array
            (
                [0] => chunked
            )

        [Connection] => Array
            (
                [0] => keep-alive
            )

        [Server] => Array
            (
                [0] => ZOOM
            )

        [x-zm-trackingid] => Array
            (
                [0] => WEB_af014e94c93acce064094d6fcc84cdcf
            )

        [X-Content-Type-Options] => Array
            (
                [0] => nosniff
            )

        [Content-Security-Policy] => Array
            (
                [0] => upgrade-insecure-requests; default-src https://*.zoom.us https://zoom.us https://d17o6on0vd932d.cloudfront.net blob: 'self'; script-src 'unsafe-eval' 'unsafe-inline' blob: about: https://ruanshi2.8686c.com https://ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js https://appsforoffice.microsoft.com https://assets.zendesk.com https://autocomplete.demandbase.com https://cdn.wootric.com https://cdncache-a.akamaihd.net https://connect.facebook.net https://consent.trustarc.com https://d.adroll.mgr.consensu.org https://d2b9h3rz4xo53c.cloudfront.net https://d24cgw3uvb9a9h.cloudfront.net https://googleads.g.doubleclick.net https://pi.pardot.com https://s.dcbap.com https://s.ytimg.com https://s3.amazonaws.com https://scout-cdn.salesloft.com https://sealserver.trustwave.com https://secure-cdn.mplxtms.com https://serve2.cheqzone.com https://snap.licdn.com https://sp.analytics.yahoo.com https://static.zdassets.com https://static2.sharepointonline.com https://tag.demandbase.com https://tpc.googlesyndication.com https://tracking.g2crowd.com https://trk.techtarget.com https://www.comeet.co https://www.dropbox.com https://www.google-analytics.com https://static.zoom.com.cn https://www.googleadservices.com/pagead/conversion_async.js https://www.googletagmanager.com/gtm.js https://optimize.google.com https://tagmanager.google.com  https://www.gstatic.com/recaptcha/releases/ https://google.com https://docs.google.com https://cse.google.com https://maps.google.com https://www.google.com https://linkedin.com https://platform.linkedin.com https://px.ads.linkedin.com https://ads.linkedin.com https://www.youtube.com https://d17o6on0vd932d.cloudfront.net https://*.ada.support https://*.adroll.com https://*.hotjar.com https://*.zoom.us https://*.zoomcloudpbx.com https://*.zoomus.cn https://*.zopim.com https://adroll.com https://zoom.us https://apis.google.com https://gstatic.zoom.com.cn 'self'; img-src https: about: blob: data: 'self'; style-src https: safari-extension: chrome-extension: 'unsafe-inline' data: 'self'; font-src https: safari-extension: chrome-extension: blob: data: 'self'; connect-src * about: blob: data: 'self'; media-src * rtmp: blob: data: 'self'; frame-src https: ms-appx-web: zoommtg: zoomus: wvjbscheme: data: 'self'; object-src 'none'; base-uri 'none';
            )

        [X-FRAME-OPTIONS] => Array
            (
                [0] => SAMEORIGIN
            )

        [Set-Cookie] => Array
            (
                [0] => zm_aid=""; Domain=.zoom.us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
                [1] => zm_haid=""; Domain=.zoom.us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
                [2] => cred=21ABCC12B70F62365DDF0B554A35C671; Path=/; Secure; HttpOnly
                [3] => _zm_page_auth=us02_c_uEv-kiHgQvKAAar4F_rPWQ; Domain=.zoom.us; Path=/; Secure; HttpOnly
                [4] => _zm_ssid=us02_c_aKIgfweHQQG5EaT2cZpweg; Domain=.zoom.us; Path=/; Secure; HttpOnly
                [5] => _zm_ctaid=f889E52dRvqoURUKV2vCUg.1599137889254.83389fb9b0d366fa454e83b4f1b894ec; Domain=.zoom.us; Expires=Thu, 03-Sep-2020 14:58:09 GMT; Path=/; Secure; HttpOnly
                [6] => _zm_chtaid=493; Domain=.zoom.us; Expires=Thu, 03-Sep-2020 14:58:09 GMT; Path=/; Secure; HttpOnly
                [7] => _zm_ctaid=bksezrrWSqOKKGvcxDRklA.1599137889254.5f69b5a447060faa456f1bb911caa7f1; Domain=.zoom.us; Expires=Thu, 03-Sep-2020 14:58:09 GMT; Path=/; Secure; HttpOnly
                [8] => _zm_chtaid=651; Domain=.zoom.us; Expires=Thu, 03-Sep-2020 14:58:09 GMT; Path=/; Secure; HttpOnly
                [9] => _zm_csp_script_nonce=RodE7nd0SZSuAxPkY_1tLw; Domain=.zoom.us; Path=/; Secure; HttpOnly
                [10] => _zm_currency=USD; Domain=.zoom.us; Expires=Fri, 04-Sep-2020 12:58:09 GMT; Path=/; Secure
                [11] => _zm_mtk_guid=3a7d99ffa1474d8e837f0d7a34d285de; Domain=.zoom.us; Expires=Sun, 01-Sep-2030 12:58:09 GMT; Path=/; Secure
            )

        [p3p] => Array
            (
                [0] => CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"
            )

        [Content-Language] => Array
            (
                [0] => en-US
            )

        [Strict-Transport-Security] => Array
            (
                [0] => max-age=31536000; includeSubDomains
            )

        [X-XSS-Protection] => Array
            (
                [0] => 1; mode=block
            )

        [Referrer-Policy] => Array
            (
                [0] => strict-origin-when-cross-origin
            )

    )

[headerNames:GuzzleHttp\Psr7\Response:private] => Array
    (
        [date] => Date
        [content-type] => Content-Type
        [transfer-encoding] => Transfer-Encoding
        [connection] => Connection
        [server] => Server
        [x-zm-trackingid] => x-zm-trackingid
        [x-content-type-options] => X-Content-Type-Options
        [content-security-policy] => Content-Security-Policy
        [x-frame-options] => X-FRAME-OPTIONS
        [set-cookie] => Set-Cookie
        [p3p] => p3p
        [content-language] => Content-Language
        [strict-transport-security] => Strict-Transport-Security
        [x-xss-protection] => X-XSS-Protection
        [referrer-policy] => Referrer-Policy
    )

[protocol:GuzzleHttp\Psr7\Response:private] => 1.1
[stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
    (
        [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #11
        [size:GuzzleHttp\Psr7\Stream:private] => 
        [seekable:GuzzleHttp\Psr7\Stream:private] => 1
        [readable:GuzzleHttp\Psr7\Stream:private] => 1
        [writable:GuzzleHttp\Psr7\Stream:private] => 1
        [uri:GuzzleHttp\Psr7\Stream:private] => php://temp
        [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
            (
            )

    )

How to fix this issue.........????

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • $contents = (string) $response->getBody(); https://stackoverflow.com/questions/30549226/guzzlehttp-how-get-the-body-of-a-response-from-guzzle-6 – DABACH Sep 08 '20 at 20:30

1 Answers1

1

"headers" => [ "Authorization" => "Basic Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=". base64_encode(CLIENT_ID.':'.CLIENT_SECRET) ]

-- You are providing this wrong, it should be like this "Basic Your base64encoded[clientid:clientsecret]", Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ= you don't need to pass this, It should be like this

  "headers" => [
        "Authorization" => "Basic ". base64_encode(CLIENT_ID.':'.CLIENT_SECRET)
    ]
Sadaf Khan
  • 13
  • 3
  • To expand upon this answer -- you want to construct the authorization key by base64 encoding `CLIENT_ID:CLIENT_SECRET` the value `Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=` in your example appears wrong. – Gibron Jun 08 '22 at 00:57