Search code examples
phpjavascriptgoogle-drive-apifederated-identitygoogle-api-js-client

Google Apps Domain-wide Delegation of Authority using javascript


Google doc ( https://developers.google.com/drive/delegation#instantiate_a_drive_service_object ) says:

For security reasons service accounts are not supported in client-side
Javascript. Service accounts for server-side Javascript is not yet
supported

I want to know is there any idea to implement it via php. The following code will depicts my thought.

<?php $token = generateToken() ?>

<script type="text/javascript">

  TOKEN = <?php echo $token ?>;
  startDriveRead(TOKEN);

</script>

The user defined php function generateToken() will do the federated authentication(it is possible) and will return the token(I don't know how to get the token).

The user defined JavaScript function startDriveRead() will use the token from the server side and will access the drive data ( I don't know whether it is possible or not).


Solution

  • Have you thought about using a javascript controller that works asynchronously to call back the server and perform the requests in php? I have yet to see a way to get a visible auth token when using the domain wide delegation of authority method to connect to google accounts.