Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionFormModel
  • ArrayUtil
  • ArrayValidator
  • AssociatedMediaBehavior
  • AuxLib
  • Changelog
  • DetailView
  • EncryptUtilTmp
  • EventsWidgetFieldFormatter
  • FailedLogins
  • FieldFormatter
  • FieldFormatterBase
  • FieldInputRenderer
  • FileFieldBehavior
  • FiltersForm
  • FilterUtil
  • FineDiff
  • FineDiffCopyOp
  • FineDiffDeleteOp
  • FineDiffInsertOp
  • FineDiffOp
  • FineDiffOps
  • FineDiffReplaceOp
  • GlobalCSSFormModel
  • GlobalImportFormModel
  • GoogleAuthenticator
  • JSONFieldsBehavior
  • JSONResponse
  • MediaFieldFormatter
  • MediaSelector
  • MobileActiveRecordFieldFormatter
  • MobileActivityFeed
  • MobileChartDashboard
  • MobileFieldFormatter
  • MobileFieldInputRenderer
  • ModuleModelNameValidator
  • MultiChildNode
  • MultiTypeAutocomplete
  • PasswordUtil
  • ProductFeature
  • ProfileWidgetLayout
  • QueryParamGenerator
  • RecordLimitBehavior
  • RecordView
  • RecordViewWidgetLayout
  • RelationshipsGridModel
  • RelationshipsJoin
  • RepairUserDataCommand
  • RequestUtil
  • RequiredIfNotSetValidator
  • ResponseUtil
  • RunMigrationScriptCommand
  • ServiceWebFormDesigner
  • Settings
  • StringUtil
  • TestEmailAction
  • TestEmailActionForm
  • ThemeGenerator
  • TimerUtil
  • TopicsFieldFormatter
  • TopicsWidgetLayout
  • TransactionalViewFieldFormatter
  • UrlUtil
  • ValidLinkValidator
  • WebFormDesigner
  • WebLeadFormDesigner
  • X2ActiveRecordBehavior
  • X2ActiveRecordFieldFormatter
  • X2ButtonColumn
  • X2ConditionList
  • X2ConsoleCommand
  • X2ControllerBehavior
  • X2DataColumn
  • X2DuplicateBehavior
  • X2Flashes
  • X2GridViewFieldFormatter
  • X2IPAddress
  • X2LeadsDataColumn
  • X2MergeableBehavior
  • X2MessageSource
  • X2MobileControllerBehavior
  • X2MobileProfileControllerBehavior
  • X2MobileQuotesControllerBehavior
  • X2MobileSiteControllerBehavior
  • X2MobileTopicsControllerBehavior
  • X2ModelConversionBehavior
  • X2ModelConversionWidget
  • X2ModelForeignKeyValidator
  • X2ModelUniqueIndexValidator
  • X2NonWebUser
  • X2StaticDropdown
  • X2StaticField
  • X2StaticFieldsBehavior
  • X2UrlManager
  • X2Validator
  • X2WidgetBehavior

Interfaces

  • AdminOwnedCredentials

Exceptions

  • CampaignMailingException
  • CodeExchangeException
  • GetCredentialsException
  • NoRefreshTokenException
  • NoUserIdException
  • StringUtilException

Functions

  • checkCurrency
  • checkDNS
  • checkServerVar
  • checkTimezone
  • decodeQuotes
  • echoIcons
  • encodeQuotes
  • exceptionForError
  • getField
  • getLanguageName
  • getModuleTitle
  • handleReqError
  • handleReqException
  • installer_t
  • installer_tr
  • isAllowedDir
  • mediaMigrationRrmdir
  • migrateMediaDir
  • printGraph
  • printR
  • renderFields
  • reqShutdown
  • RIP
  • translateOptions
  • tryGetRemote
  • Overview
  • Package
  • Class
  • Tree

Class GoogleAuthenticator

Wrapper class for interaction with Google's API and authentication methods. This is designed to handle all user authentication and returning of Google API Client classes in an easy to use manner. Much of the code is from Google's stock PHP API examples, but it has been modified to be usable with our software and as such some of the comments/classes are Google developers' not mine.

Located at x2engine/protected/components/GoogleAuthenticator.php
Methods summary
public
# __construct( )

Constructor that sets up the Authenticator with all the required data to connect to Google properly.

Constructor that sets up the Authenticator with all the required data to connect to Google properly.

public String
# getStoredCredentials( String $userId )

Retrieved stored credentials for the provided user ID.

Retrieved stored credentials for the provided user ID.

Parameters

$userId
String
$userId User's ID.

Returns

String
Json representation of the OAuth 2.0 credentials.
public
# storeCredentials( Integer $userId, String $credentials )

Store OAuth 2.0 credentials in the application's database.

Store OAuth 2.0 credentials in the application's database.

Parameters

$userId
Integer
$userId User's ID.
$credentials
String
$credentials Json representation of the OAuth 2.0 credentials to store.
public String
# exchangeCode( String $authorizationCode )

Exchange an authorization code for OAuth 2.0 credentials.

Exchange an authorization code for OAuth 2.0 credentials.

Parameters

$authorizationCode
String
$authorizationCode Authorization code to exchange for OAuth 2.0 credentials.

Returns

String
Json representation of the OAuth 2.0 credentials.

Throws

CodeExchangeException
An error occurred.
public Userinfo
# getUserInfo( String $credentials )

Send a request to the UserInfo API to retrieve the user's information.

Send a request to the UserInfo API to retrieve the user's information.

Parameters

$credentials
String
credentials OAuth 2.0 credentials to authorize the request.

Returns

Userinfo
User's information.

Throws

NoUserIdException
An error occurred.
public String
# getAuthorizationUrl( String $state )

Retrieve the authorization URL.

Retrieve the authorization URL.

Parameters

$state
String
$emailAddress User's e-mail address.

Returns

String
Authorization URL to redirect the user to.
public String
# getCredentials( String $authorizationCode, String $state )

Retrieve credentials using the provided authorization code.

Retrieve credentials using the provided authorization code.

This function exchanges the authorization code for an access token and queries the UserInfo API to retrieve the user's e-mail address. If a refresh token has been retrieved along with an access token, it is stored in the application database using the user's e-mail address as key. If no refresh token has been retrieved, the function checks in the application database for one and returns it if found or throws a NoRefreshTokenException with the authorization URL to redirect the user to.

Parameters

$authorizationCode
String
authorizationCode Authorization code to use to retrieve an access token.
$state
String
state State to set to the authorization URL in case of error.

Returns

String
Json representation of the OAuth 2.0 credentials.

Throws

NoRefreshTokenException
No refresh token could be retrieved from the available sources.
public
# flushCredentials( boolean $full = true )

Sometimes, terrible things happen. When an auth error occurs or a problem with the credentials arises, flush every place they're stored immediately to stop any errors badly provided credentials may be causing.

Sometimes, terrible things happen. When an auth error occurs or a problem with the credentials arises, flush every place they're stored immediately to stop any errors badly provided credentials may be causing.

Parameters

$full
boolean
full Whether or not to flush all credentials or just temporary ones. This is useful because the token in the session will not contain a refresh token in most cases, but the refresh token may still be valid. In that case, just clearing the session tokens will allow for another attempt using the refresh token.
public String|boolean
# getAccessToken( Integer $userId = null )

This function is used to get the current access token. This function is vital to the class as it allows any code using the Authenticator to discover if a connection to Google has been made and if any actions connecting to Google can procede. This function is called in a large number of places as a gate to continuing integration tasks.

This function is used to get the current access token. This function is vital to the class as it allows any code using the Authenticator to discover if a connection to Google has been made and if any actions connecting to Google can procede. This function is called in a large number of places as a gate to continuing integration tasks.

Parameters

$userId
Integer
$userId The ID of the current User

Returns

String|boolean
Returns either the JSON encoded access token, or false on failure
public
# getDriveService( )
public
# getCalendarService( )
public
# setErrors( mixed $message )
public
# getErrors( )
Properties summary
public string $clientId ''
#

Client ID of the Google API Project

Client ID of the Google API Project

public string $clientSecret ''
#

Client secret of the Google API Project

Client secret of the Google API Project

public string $redirectUri ''
#

Redirect URI for the authentication request

Redirect URI for the authentication request

public array $scopes array( 'https://www.googleapis.com/auth/plus.login', // Google+ login required to login with Google 'https://www.googleapis.com/auth/drive', // Drive required for drive integration 'https://www.googleapis.com/auth/userinfo.email', // Email required for Google login 'https://www.googleapis.com/auth/userinfo.profile', // Basic profile info required for Google login 'https://www.googleapis.com/auth/calendar', // Calendar required for Calendar sync 'https://www.googleapis.com/auth/calendar.readonly', // Read only Calendar required for Calendar list )
#

A list of scopes required by the Google API to use for Google Integration within the software. This list defines the permissions that Google will ask for when a user is authenticating with them and X2.

A list of scopes required by the Google API to use for Google Integration within the software. This list defines the permissions that Google will ask for when a user is authenticating with them and X2.

X2CRM Documentation API documentation generated by ApiGen 2.8.0