[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace OAuth\OAuth2\Service; 4 5 use OAuth\OAuth2\Token\StdOAuth2Token; 6 use OAuth\Common\Http\Exception\TokenResponseException; 7 use OAuth\Common\Http\Uri\Uri; 8 9 class Google extends AbstractService 10 { 11 /** 12 * Defined scopes -- Google has way too many Application Programming Interfaces 13 */ 14 const SCOPE_ADSENSE = 'https://www.googleapis.com/auth/adsense'; 15 const SCOPE_ADWORDS = 'https://adwords.google.com/api/adwords/'; 16 const SCOPE_GAN = 'https://www.googleapis.com/auth/gan'; // google affiliate network...? 17 const SCOPE_ANALYTICS = 'https://www.googleapis.com/auth/analytics.readonly'; 18 const SCOPE_BOOKS = 'https://www.googleapis.com/auth/books'; 19 const SCOPE_BLOGGER = 'https://www.googleapis.com/auth/blogger'; 20 const SCOPE_CALENDAR = 'https://www.googleapis.com/auth/calendar'; 21 const SCOPE_CLOUDSTORAGE = 'https://www.googleapis.com/auth/devstorage.read_write'; 22 const SCOPE_CONTACT = 'https://www.google.com/m8/feeds/'; 23 const SCOPE_CONTENTFORSHOPPING = 'https://www.googleapis.com/auth/structuredcontent'; // what even is this 24 const SCOPE_CHROMEWEBSTORE = 'https://www.googleapis.com/auth/chromewebstore.readonly'; 25 const SCOPE_DOCUMENTSLIST = 'https://docs.google.com/feeds/'; 26 const SCOPE_GOOGLEDRIVE = 'https://www.googleapis.com/auth/drive'; 27 const SCOPE_GOOGLEDRIVE_FILES = 'https://www.googleapis.com/auth/drive.file'; 28 const SCOPE_GMAIL = 'https://mail.google.com/mail/feed/atom'; 29 const SCOPE_GPLUS_ME = 'https://www.googleapis.com/auth/plus.me'; 30 const SCOPE_GPLUS_LOGIN = 'https://www.googleapis.com/auth/plus.login'; 31 const SCOPE_GROUPS_PROVISIONING = 'https://apps-apis.google.com/a/feeds/groups/'; 32 const SCOPE_GOOGLELATITUDE = 33 'https://www.googleapis.com/auth/latitude.all.best https://www.googleapis.com/auth/latitude.all.city'; 34 // creepy stalker api... 35 const SCOPE_MODERATOR = 'https://www.googleapis.com/auth/moderator'; 36 const SCOPE_NICKNAME_PROVISIONING = 'https://apps-apis.google.com/a/feeds/alias/'; 37 const SCOPE_ORKUT = 'https://www.googleapis.com/auth/orkut'; // evidently orkut still exists. who knew? 38 const SCOPE_PICASAWEB = 'https://picasaweb.google.com/data/'; 39 const SCOPE_SITES = 'https://sites.google.com/feeds/'; 40 const SCOPE_SPREADSHEETS = 'https://spreadsheets.google.com/feeds/'; 41 const SCOPE_TASKS = 'https://www.googleapis.com/auth/tasks'; 42 const SCOPE_URLSHORTENER = 'https://www.googleapis.com/auth/urlshortener'; 43 const SCOPE_USERINFO_EMAIL = 'https://www.googleapis.com/auth/userinfo.email'; 44 const SCOPE_USERINFO_PROFILE = 'https://www.googleapis.com/auth/userinfo.profile'; 45 const SCOPE_USER_PROVISIONING = 'https://apps-apis.google.com/a/feeds/user/'; 46 const SCOPE_WEBMASTERTOOLS = 'https://www.google.com/webmasters/tools/feeds/'; 47 const SCOPE_YOUTUBE = 'https://gdata.youtube.com'; 48 49 const SCOPE_GLASS_TIMELINE = 'https://www.googleapis.com/auth/glass.timeline'; 50 const SCOPE_GLASS_LOCATION = 'https://www.googleapis.com/auth/glass.location'; 51 52 53 54 /** 55 * {@inheritdoc} 56 */ 57 public function getAuthorizationEndpoint() 58 { 59 return new Uri('https://accounts.google.com/o/oauth2/auth'); 60 } 61 62 /** 63 * {@inheritdoc} 64 */ 65 public function getAccessTokenEndpoint() 66 { 67 return new Uri('https://accounts.google.com/o/oauth2/token'); 68 } 69 70 /** 71 * {@inheritdoc} 72 */ 73 protected function parseAccessTokenResponse($responseBody) 74 { 75 $data = json_decode($responseBody, true); 76 77 if (null === $data || !is_array($data)) { 78 throw new TokenResponseException('Unable to parse response.'); 79 } elseif (isset($data['error'])) { 80 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 81 } 82 83 $token = new StdOAuth2Token(); 84 $token->setAccessToken($data['access_token']); 85 $token->setLifetime($data['expires_in']); 86 87 if (isset($data['refresh_token'])) { 88 $token->setRefreshToken($data['refresh_token']); 89 unset($data['refresh_token']); 90 } 91 92 unset($data['access_token']); 93 unset($data['expires_in']); 94 95 $token->setExtraParams($data); 96 97 return $token; 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |