You are here

public function FormAssemblyRequest::authorize in FormAssembly 7

Redirect the user so to authorize the application using OAuth2.0.

Return value

bool|mixed Returns an access token if the user has already authorized.

File

includes/FormAssemblyRequest.php, line 69
Authorizes the current site and handles API requests to FormAssembly.

Class

FormAssemblyRequest
@file Authorizes the current site and handles API requests to FormAssembly.

Code

public function authorize() {
  $token = $this
    ->getToken();
  if ($token) {
    return $token;
  }
  $params = array(
    'type' => 'web',
    'client_id' => $this->clientId,
    'redirect_uri' => $this->returnUrl,
    'response_type' => 'code',
  );
  $auth_uri = $this->apiHost . '/' . $this->authEndpoint . '?' . drupal_http_build_query($params);
  drupal_goto($auth_uri);
  return NULL;
}