Implementing Oauth2 login, Fatal error: Class 'Google_Service' not found

后端 未结 8 1399
情书的邮戳
情书的邮戳 2020-12-06 03:02

I am updating my website\'s login system from LightOpenID to Google\'s Oauth 2.0.

When I require the Client.php and the Service/Oauth2.php I get an error

相关标签:
8条回答
  • 2020-12-06 03:24

    As of Nov 2016

    require_once ... 'vendor/autoload.php';
    
    0 讨论(0)
  • 2020-12-06 03:26

    Make sure you add the line BEFORE any other Google "require_once" lines.

    require_once 'google-api-php-client/autoload.php';
    

    I had it last and it had me scratching my head for a good 10 minutes.

    0 讨论(0)
  • 2020-12-06 03:35

    The new way of doing this (circa early 2016) is

    require_once("Google/autoload.php");
    

    (Assuming you have already set your include path to have /path/to/google-api-php-client/src)

    0 讨论(0)
  • 2020-12-06 03:37

    After following what Durandal had posted I tried it, but the new path for me is :

    require_once 'google-api-php-client/src/Google/autoload.php';
    

    Once I made this changed it worked. Thanks for the help.

    0 讨论(0)
  • 2020-12-06 03:40

    While working with Google API integration

    Fatal error: Class 'abc' not found

    error comes when there is definitely something different between the library you have in composer.json above, and the library that is actually being auto-loaded.

    had same problem just changed in my composer.json

    {"require": {"google/apiclient": "1.0.*@beta"}}
    

    to

    {"require": {"google/apiclient": "2.0.*"}}
    

    and then execute php composer.phar update (make sure you give right path for .phar file)

    0 讨论(0)
  • 2020-12-06 03:41

    To this version https://github.com/google/google-api-php-client this is a posible solution

    set_include_path("google-api-php-client/src/" . PATH_SEPARATOR . get_include_path());
    
    //.....
    
    require_once 'Google/Service.php';
    //.....
    
    0 讨论(0)
提交回复
热议问题