Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Web Sever access ? #27

Open
crisp-github opened this issue Nov 18, 2014 · 5 comments
Open

Support for Web Sever access ? #27

crisp-github opened this issue Nov 18, 2014 · 5 comments

Comments

@crisp-github
Copy link

Hi,

We got the package working with a Service Account but would like to use the Web Server authorisation to avoid needing to add the service email to each account. Any suggestions ?

I'm wondering if we modify this package or should be looking for a different package ?

Cheers!

@thujohn
Copy link
Owner

thujohn commented Nov 18, 2014

Hi.

I made this package to simply create an app and not manage authorizations after.

I didn't check other packages but you can modify this. And if you want you make a PR after.

@crisp-github
Copy link
Author

Hi thujohn ,we did modify the package to use web server authorisation. But we assume the refresh token is set in advance. It is not in a state for a PR unfortunately. But if someone wants some pointers I can help.

@rayne128
Copy link

rayne128 commented Dec 8, 2014

Hello crisp, im very interested on your approach. Mind sharing your how did you achieve it? Thanks

@crisp-github
Copy link
Author

Hi, sure. We modified AnalyticsServiceProvider.php In our set we use a patch to modify the file in the vendor directory. Just modify the register() method for how $client is created. The main bit of code is:

  •  $client = new \Google_Client();
    
  •  $client->setAccessType('offline');
    
  •  $client->setClientId($this->credentials->client_id);
    
  •  $client->setClientSecret($this->credentials->client_secret);
    
  •  $client->addScope("https://www.googleapis.com/auth/analytics.readonly");
    
  •  // Need to make this after setting the client above because it initiates a request
    
  •  $client->refreshToken($this->credentials->refresh_token);
    

You can see we added a class variable $credentials and set that in the register function by pulling the credentials form our DB. You could hardcode the value there to get started.

@rayne128
Copy link

Thanks for the help! The code snippet you provided is enough to get me started. Thanks again really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants