李帅

1.使用谷歌服务账号进行验证

...@@ -39,38 +39,54 @@ class GooglePayment implements PaymentInterface ...@@ -39,38 +39,54 @@ class GooglePayment implements PaymentInterface
39 39
40 private function getGoogleClient() 40 private function getGoogleClient()
41 { 41 {
42 - // load our config.json that contains our credentials for accessing google's api as a json string 42 +// // load our config.json that contains our credentials for accessing google's api as a json string
43 - $configJson = public_path().'/client_secret_724392566830-jv6gqcb7vv8q9vavihhu5siccdit35op.apps.googleusercontent.com.json'; 43 +// $configJson = public_path().'/client_secret_724392566830-jv6gqcb7vv8q9vavihhu5siccdit35op.apps.googleusercontent.com.json';
44 +//
45 +// // define an application name
46 +// $applicationName = 'Parlando一言临境';
47 +//
48 +// // create the client
49 +// $client = new \Google_Client();
50 +// $client->setApplicationName($applicationName);
51 +// try{
52 +// $client->setAuthConfig($configJson);
53 +// }catch (\Google\Exception $exception){
54 +// Log::debug('用户授权出错了'.$exception->getMessage());
55 +// }
56 +// $client->setAccessType('offline'); // necessary for getting the refresh token
57 +// $client->setApprovalPrompt ('force'); // necessary for getting the refresh token
58 +// // scopes determine what google endpoints we can access. keep it simple for now.
59 +// $client->setScopes(
60 +// [
61 +// \Google\Service\Oauth2::USERINFO_PROFILE,
62 +// \Google\Service\Oauth2::USERINFO_EMAIL,
63 +// \Google\Service\Oauth2::OPENID,
64 +// \Google_Service_AndroidPublisher::ANDROIDPUBLISHER,
65 +// \Google\Service\Drive::DRIVE_METADATA_READONLY // allows reading of google drive metadata
66 +// ]
67 +// );
68 +// $client->setIncludeGrantedScopes(true);
69 +//
70 +// // google 服务端默认获得受权
71 +// $client->useApplicationDefaultCredentials();
72 +// // 设置 google client_email
73 +// $client->setSubject("client_email");
44 74
45 - // define an application name
46 - $applicationName = 'Parlando一言临境';
47 75
48 - // create the client 76 + $credentials_file = public_path().'/pc-api-7482901338487549764-603-566eccf76b91.json';
49 $client = new \Google_Client(); 77 $client = new \Google_Client();
50 - $client->setApplicationName($applicationName);
51 try{ 78 try{
52 - $client->setAuthConfig($configJson); 79 + $client->setAuthConfig($credentials_file);
53 }catch (\Google\Exception $exception){ 80 }catch (\Google\Exception $exception){
54 Log::debug('用户授权出错了'.$exception->getMessage()); 81 Log::debug('用户授权出错了'.$exception->getMessage());
55 } 82 }
56 - $client->setAccessType('offline'); // necessary for getting the refresh token 83 + $applicationName = 'Parlando一言临境';
57 - $client->setApprovalPrompt ('force'); // necessary for getting the refresh token 84 + $client->setApplicationName($applicationName);
58 - // scopes determine what google endpoints we can access. keep it simple for now.
59 $client->setScopes( 85 $client->setScopes(
60 [ 86 [
61 - \Google\Service\Oauth2::USERINFO_PROFILE,
62 - \Google\Service\Oauth2::USERINFO_EMAIL,
63 - \Google\Service\Oauth2::OPENID,
64 \Google_Service_AndroidPublisher::ANDROIDPUBLISHER, 87 \Google_Service_AndroidPublisher::ANDROIDPUBLISHER,
65 - \Google\Service\Drive::DRIVE_METADATA_READONLY // allows reading of google drive metadata
66 ] 88 ]
67 ); 89 );
68 -// $client->setIncludeGrantedScopes(true);
69 -
70 - // google 服务端默认获得受权
71 -// $client->useApplicationDefaultCredentials();
72 - // 设置 google client_email
73 -// $client->setSubject("client_email");
74 90
75 return $client; 91 return $client;
76 } 92 }
......