To authorize the application, you need to call the URL for the OAuth2 authorization process. This URL lives in the API provider documentation. For example, Google has this URL:
https://accounts.google.com/o/auth2/auth
You also need to specify several query parameters at this link:
cliend_idredirect_uriscope: , . , Facebook -. scope API. Gougle T scope - https://www.googleapis.com/auth/tasks. Google, scope https://www.googleapis.com/auth/tasks https://docs.google.com/feedsresponse_type: code - , , code , .state: , , (CSRF) . , (, ).
$_SESSION['state'] = rand(0,999999999);
$authorizationUrlBase = 'https://accounts.google.com/o/oauth2/auth';
$redirectUriPath = '/oauth2callback.php';
$queryParams = array(
'client_id' => '240195362.apps.googleusercontent.com',
'redirect_uri' => (isset($_SERVER['HTTPS'])?'https://':'http://') .
$_SERVER['HTTP_HOST'] . $redirectUriPath,
'scope' => 'https://www.googleapis.com/auth/tasks',
'response_type' => 'code',
'state' => $_SESSION['state'],
'approval_prompt' => 'force',
'access_type' => 'offline'
);
$goToUrl = $authorizationUrlBase . '?' . http_build_query($queryParams);
include 'access_request_template.php';
, Google -, :
https://developers.google.com/accounts/docs/OAuth2WebServer?hl=el#formingtheurl