M
M
maiskiykot2019-07-27 13:32:46
API
maiskiykot, 2019-07-27 13:32:46

Why doesn't google calendar api accept authorization code?

I get an authorization code for the Google API. I insert it into curl and try to get the timezone. Answer: bad token. Tell me: where is the joint?

$url_settings = 'https://www.googleapis.com/calendar/v3/users/me/settings/timezone';
        
        $ch = curl_init();        
        curl_setopt($ch, CURLOPT_URL, $url_settings);        
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);    
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer 4/jwEgFJuak3-Gp8ZjR9Bk3iyPgYGi3xwO3ADPzfDf13хххххххххsah2F_0kqV4FknIWbMAeYH1fl8nl_M8'));    
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    
        $data = json_decode(curl_exec($ch), true); echo '<pre>';print_r($data);echo '</pre>';
        $http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);        
        if($http_code != 200) 
            echo('Error : Failed to get timezone');

Titles
HTTP/1.1 401 Unauthorized Vary: X-Origin WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token Content-Type: application/json; charset=UTF-8 Date: Sat, 27 Jul 2019 09:35:46 GMT Expires: Sat, 27 Jul 2019 09:35:46 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Alt-Svc: quic=":443"; ma=2592000; v="46,43,39" Accept-Ranges: none Vary: Origin,Accept-Encoding Transfer-Encoding: chunked {"error": {"errors": [{"domain": "global","reason": "authError","message": "Invalid Credentials","locationType": "header","location": "Authorization"}],"code": 401,"message": "Invalid Credentials"} }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question