google-drive-sdk,google-oauth,google-api-php-client , Google Drive help required access to own Drive account


Google Drive help required access to own Drive account

Question:

Tag: google-drive-sdk,google-oauth,google-api-php-client

I want to access my own google drive on web page but allow anyone to upload files and restrict download access or show only limited file to user for downloading.

Drive API assumes that I will access another users credentials. But what I want is opposite, anyone can view my files (restricted what to view) but is free to upload. I have google nearly 6+ hours and didn't found any solution

Any Help Appreciated Thanks


Answer:

You say "Drive API assumes that I will access another users credentials" but this isn't correct. Calls to Drive include an Access Token, and it is that which determines which Drive account the call will access. Drive makes no assumptions about how that Access Token was obtained or which account it refers to.

All of the examples show how an Access Token is obtained for an end user, since that is the more complex flow. Your requirement is very much simpler.

All you need to do is:-

  1. Obtain a refresh token (see How do I authorise a background web app without user intervention? (canonical ?))
  2. Store that refresh token in your PHP application. Make sure it's secure
  3. When you need to access your Drive account, use the refresh token to obtain an access token as described at https://developers.google.com/accounts/docs/OAuth2WebServer#refresh

Related:


Advanced Drive Services in Addons


google-apps-script,google-drive-sdk
I have a Google Script that uses the Advanced Drive API service and am now looking to convert this script into an Add-on. However the Drive API needs to be enabled manually by the user before using the service inside the Apps Script. Is it possible to use the advanced...

Google Drive revokes my token


java,google-drive-sdk
I am new to google drive and started with the tutorial quickstart. After numerous attampts I run the program successfully. However I had permission and authorisation problems when I was trying to delete files. Drive service = getDriveService(); service.files().delete("FileId").execute(); So I decide to change the URL in the client_secret.json, From:...

Google Analytics Embed API: Display specific account data, not authenticated users


google-api,google-oauth,google-analytics-api
I have this example - Embed API Third Party Visualizations - working locally and on a test server, but I'm unsure of what I need to do to ONLY display our organization's Google Analytics data instead of the user's personal GA account. I created the project and clientID within our...

Directory sandboxed access for Google Drive / Dropbox API / RemoteStorage apps?


html5,google-drive-sdk,dropbox-api
Is there a way to get sandboxed, user-selected directory access on any major file service without first getting read level access to their entire filesystem? There's a lot of talk about "unhosted" static webapps that allow users to access their data from a 3rd party file service (Google Drive, Dropbox,...

Google Drive - How to List all Files in a specified folder


php,google-apps-script,google-api,google-drive-sdk,xampp
Hi I am stuck here with this situation, I have tried a number of different approaches but I cannot get what I am after. Situation: I have a large number of files in folders hosted on google drive. For instance a single client folder for reports has between 2000-10000 files(this...

Google Drive API VB.NET Parent Folder of a Folder


vb.net,google-drive-sdk,folder,parent
I am trying to work with Google Drive API with vb.net I have seen a lot of post but I am not able to understand how to choose the right folder to add a file. I have a lot of "Backup" folder but, I assume now, I want to add...

Google Drive file download via http


java,android,http,google-drive-sdk
There is a link to Google Drive file accessible to anyone without authentication. Is there any way to download that file using just link and some sort of http client? Most of examples around are relying on Drive API and file IDs, however I'd like to stick with more lightweight...

Google authentification with “devise” fail


ruby-on-rails,devise,google-oauth,omniauth
I want to create a GOOGLE authentification in my app. So in set up "omniauth" and "devise" correctly (I think). In my layout folder in "_header.html.erb" view : <% if user_signed_in? %>Signed in as <%= current_user.name %>. Not you? <%= link_to "Sign out", destroy_user_session_path,:method => :delete %> <% else %>...

How to save my data in a cloud?


google-drive-sdk,cloud,server,dropbox
I don't know if this is possible, but I would like to save some data of my website, like images and documents in a cloud like dropbox or google drive and I want that these data are available and visible to someone looking my site. is it possible? (My intention...

Prompt user to enter password - Google OpenID Connect


google-oauth,google-openid,openid-connect,google-oauth2
We are trying to use Google's OpenID Connect for a business web app but are concerned that the user will leave the app open and an unauthorized user will sign-in because the user is still signed into Google so OpenID Connect just let's them right in. We've tried using max_auth_age=0...

How to authenticate a java application for the Google Contacts API?


java,google-oauth,gdata,google-contacts
I've had a java application running for a few years that synced some contacts from some database into the gmail account of a customer. This stopped working a few days ago, presumably because Google stopped supporting the simple username/password authentication. First question: Am I correct in assuming that the only...

401 Unauthorized - Google Drive API


asp.net,.net,vb.net,google-drive-sdk
I'm working with the Google APIs for the first time and I'm having problems trying to download files with the File object "downloadUrl" property. I'm currently using the "Service Account" option with the associated service account email and P12 certificate. However, the URL returned "https://doc-08-68-docs.googleusercontent.com/docs/securesc/bteg36c1tifegg79l2ov17og25612tet/gk7kn52ahe4d0to7d6hte9f0f2hv47e4/1434132000000/11750183130219432819/11750183130219432819/0BziIKv2_NWCxc3RhcnRlcl9maWxl?e=download&gd=true" returns a 401 - Unauthorized...

google Oauth login in https server


javascript,meteor,google-oauth
I have an meteor web server on Https server say https://popasdesasdasd.com. I added this url to the Javascript Origin uri and https://popasdesasdasd.com/_oauth/google?close in redirect uri. On request, it says mismatch uri and asked to put http://popasdesasdasd.com/_oauth/google?close in redirect uri. Adding that gives me an error of Uncaught SecurityError: Blocked a...

Google AdEx Seller API doesn't support Service accounts


google-oauth,google-api-python-client,google-reseller-api
I want to pull periodic reports via Google Seller API. Is there a way, to login into Seller account without having to go via regular OAuth redirection ?

Newbie Google Drive API (PHP) confusion - what guide/library to use?


php,api,google-drive-sdk
I have a mobile site m.example.com - from a phone I want visitors to choose a file from Google Drive, and send it to the server that hosts m.example.com. Essentially emulating a simple <input type="file"> file upload as on a desktop. From what I understand the workflow is as follows:...

Insert file using Google Drive API?


java,google-drive-sdk
Based on Google Drive API reference guiding how to insert file Files.insert // File's metadata. File body = new File(); body.setTitle(title); body.setDescription(description); body.setMimeType(mimeType); // File's content. java.io.File fileContent = new java.io.File(filename); FileContent mediaContent = new FileContent(mimeType, fileContent); try { File file = service.files().insert(body, mediaContent).execute(); // Uncomment the following line to...

How to login with another user when using Google for login?


php,authentication,google-api,google-oauth
I am using Google login to authenticate user before they login to my website. Here is what I am doing. User comes to my website Click on login button Login with Google account if user pass google authentication, session is set when user click on logout, session is destroyed Basic...

Google Drive API: I have to fetch only files in that folder without trashed files


c#,c#-4.0,google-api,google-drive-sdk
I am trying to get a list of files in a folder on Google drive using the Google drive API. When I make my request I am getting a list of child elements in that folder including previous deleted files. How do I get only the files that are in...

Gmail API: How to get access token?


php,google-api,google-oauth,google-api-php-client,gmail-api
I am testing the Gmail API. So far I have done the following: I have created the project in the Google Developers Console I have enabled the Gmail API. I have created a new Client ID and the client secret. In my PHP script I have installed the PHP Client...

How to use token obtained using GoogleAuthUtil class to get user information?


java,android,oauth-2.0,google-oauth
I am building an Android app in which I want to authenticate user using their google account. I am using GoogleAuthUtil class to obtain token from google as shown below protected String fetchToken() throws IOException{ try { return GoogleAuthUtil.getToken(act, email, scope); } catch (GoogleAuthException e) { e.printStackTrace(); } return null;...

Google Drive API 500 null errors when copying


google-api,google-drive-sdk,google-api-php-client,google-api-client
I'm getting this error message (100% of the time) when copying a shared file, using the latest version of php library. And I'm getting the same response via the API explorer: developers.google.com/drive/v2/reference/files/copy Google_Exception: Error calling POST https://www.googleapis.com/drive/v2/files/#fileid#/copy: (500) { "error": { "code": 500, "message": null } } This issue seem...

How can I make a copy of a file in Google Drive via Python?


python,google-drive-sdk,google-oauth
I wrote a short function in Google Apps script that can make a copy of a specific file that is stored on Google Drive. The purpose of it is that this file is a template and every time I want to create a new document for work I make a...

access drive with access token


php,google-drive-sdk,google-spreadsheet,google-oauth
struggling to understand the oauth2 token and refresh token processes ive got this code $url = 'https://www.googleapis.com/oauth2/v3/token'; $data = array('client_id' => 'clientid', 'client_secret' => 'secret','refresh_token' => 'token','grant_type' => 'refresh_token'); $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded", 'method' => 'POST', 'approval_prompt'=>'force', 'access_type'=>'offline', 'content' => http_build_query($data), ), ); $context...

Google Drive API (GTL) - Create multiple folder paths in order?


ios,objective-c,swift,google-drive-sdk,google-api-objc-client
I'm using the Google APIs Client Library for Objective-C (GTL) to access the Google Drive API. According to it's Introduction to the Google APIs Client Library for Objective-C, Query execution by the service is inherently asynchronous. Which means when you try to create a path like: root/a/b/c, before you can...

Oauth2 using Python 3.4 and Django 1.7


python,django,python-3.x,google-oauth
I'm trying to authorize my django application using oauth2 in order to interact with the google content for shopping API. However, I'm experiencing issues with oauth2 along the way. I have oauth2client and google-api-python-client installed. My view is as follows: CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secret.json') FLOW = flow_from_clientsecrets( CLIENT_SECRETS, scope='https://www.googleapis.com/auth/content', redirect_uri='https://127.0.0.1:8000/oauth2/oauth2callback')...

What is the preferred method of using Google for sign-in?


authentication,oauth-2.0,google-plus,google-oauth
Google has a habit of providing multiple means to achieve a goal. And of ditching services when they feel like it. If I would need to implement a "sign-in with Google" authentication feature today, which one should I pick? Google Sign-In or Google+ Sign-In? Or to put it differently: which...

Any way te read an excel file from a Google Sheet?


excel,google-apps-script,google-drive-sdk,google-spreadsheet,google-apps
in my organization we work with Google Apps but we have one file that we need to maintain in Excel due to its complexity. All my other spreadsheets are Google Sheets and a lot of them need to get data from that excel file. So my question is: is there...

Gmail API: example of a request to the API


php,google-api,google-oauth,google-api-php-client,gmail-api
I am trying access the Gmail API with my application. I should have done properly all the setup and I am testing a request to the API, in the specific the request to get the messages as read only. My code: public function gmail_get_messages() { $client = new Google_Client(); $client->setApplicationName("Gmail...

Adding google api client to codeigniter


php,codeigniter,google-drive-sdk,google-api-php-client
I want to upload files to google drive using php in codeigniter. First of all i am trying to integrate google api client to codiginator. I have uploaded all the files in to my third_party folder. it look like this I i have created a file called google.php inside my...

Can one track the usage of a shared resource from google drive


google-drive-sdk
Does anyone here know if you on Google Drive somehow can track if a public shared link to a file have been used? That is, the resource have been downloaded, viewed or otherwise "touched"?...

Google Calendar API event insert always return 404 “not found” error iOS


ios,google-calendar,google-oauth
I'm tried the calendar insert example from here : https://developers.google.com/google-apps/calendar/v3/reference/events/update No matter which property i use, i always get the 404 "not found" error. Anyone can shed some light on this? Many thanks!!! PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/q4amm7fsk9rq97r3dmhisjie84&key={YOUR_API_KEY} Content-Type: application/json Request Body : { attendees = ( { email = "[email protected]"; } );...

Providing login_hint option for Google Oauth2 redirect


oauth,google-api,google-oauth
I'm passing in login_hint=1 option as part of Oauth2 request query string but this doesn't appear when I receive a callback from Google Oauth2 after accepting it. I'm only getting: google/oauth2callback?code=4/vadsdaalijfqwo8fdjqojcxadassddsa# I was expecting 1 (which is user id) to come back as part of callback. How do I make...

Pass Comments & Suggested Edits from a Google Document to a Google Sheet


google-apps-script,google-drive-sdk
Fellow Stackers. I'm using a Google Apps Script to (a) capture all "Comments" in a Google Document... ...and (b) list them in a column of a Google Sheet... However, I'm wondering if it's possible to... (1) Array "Comments" into individual cells down a column in my Sheet rather than into...

How to create a Google form programatically with python ?Is it possible to do so by appscript and python interfacing or something like that?


python,google-drive-sdk
How to create a Google form programatically with python ? Do they provide some api like drive api to do so ? Is it possible to interface python with Google appscript ? https://www.youtube.com/watch?v=38H7WpsTD0M Here they are talking about creating a form with a form using app script . Thank you...

How can I insert data (event) into Google Calendar with PHP?


php,google-calendar,google-oauth,google-api-php-client,service-accounts
I am trying to insert events into Google Calendar, but I get errors everytime. I've been searching for hours to get answer, but I found nothing for my problem. I tested a lot of examples, without success. I'm new in Google Calendar, and I can't really understand the google api...

What is the correct mechanism to authenticate to Google in a standalone Python script?


python,google-oauth,gdata,google-contacts
I've got some code that I'm using to extract email address from Gmail contacts into text file. It's a simple Python script that runs in a cron job, and is based on the Python gdata library (currently v2.0.18). As of earlier this month, this no longer works due to Google...

google-apps-script count files in folder


if-statement,google-apps-script,count,google-drive-sdk
I've had a search but cannot seem to find what I am looking for. I am seeking the code to enable me to do this pseudocode: Count number of files in specific Google Drive folder (by folder Id) If file count is above 'x' do this {other piece of code}...

Google Drive API every time asking for authentication code


php,curl,google-drive-sdk
I'm using google drive api to upload a file to google drive using php, but it every time asking me for authentication code fof my application. I have followed the steps given in the URL below https://developers.google.com/drive/web/quickstart/quickstart-php My Code: require_once 'src/Google/autoload.php'; $client = new Google_Client(); // Get your credentials from...

Can I associate a user's account with an action to the drive API?


javascript,oauth,google-drive-sdk,google-spreadsheet,google-oauth
We're looking to make a little webapp to manage our week-long nerf war (humans vs zombies to be precise), and we're thinking about how easy it would be to have Google Sheets be our only backend, and our frontend be entirely javascript/html/css. Let's say there's two actions that can be...

What does “offline” access in OAuth mean?


oauth,google-oauth,google-oauth2
What exactly does the word "offline" mean with regard to the offline access granted by an OAuth server? Does it mean that the resource server will return data about the user even when the user is logged out of the third-party application or when the user is logged out of...

Google SignIn State


login,oauth-2.0,google-oauth
I'm trying to build a Google signin button into my website. I'm trying to avoid using their built-in button. The code below works to sign in a user, but I can't figure out how to make my webpage remember that they're signed in when the user refreshes the page, or...

Removing permissions of the extensions


javascript,google-chrome-extension,google-drive-sdk,access-token
I have an extension that first asks for permissions to access Google Drive files. The extension is almost empty except in the popup I load this js: chrome.identity.getAuthToken({ 'interactive': true }, function(token) { // Use the token. console.log('Request Token') console.log(token) chrome.identity.removeCachedAuthToken( { 'token': token }, function () {}) console.log('Removed token')...

401 Unauthorized when authentificating with Google for hybrid applications


google-api,google-oauth
I want to use native applications and a web server to get refresh tokens to use for some operations (on google drive). Client ids and secrets have been generated for both the native and the web application using the Google developer console. I'm trying to generate authcodes from the native...

Cannot refresh token from google api OAuth2


php,google-oauth
Here is my php script RefreshToken.php <?php $url = 'https://accounts.google.com/o/oauth2/token'; $post_data = array( 'code' => 'xxxxxxxx', 'client_id' => 'xxxxxxxxxxx', 'client_secret' => 'xxxxxxxxxxxxx', 'redirect_uri' => 'http://localhost/googleapi/AuthenticationCode.php', 'grant_type' => 'authorization_code', ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result =...

How to browse files from projects google drive


php,google-drive-sdk
i have created project in google console with service type credentials. I have downloaded p12 key file, and then wrote sample code for inserting file to test it: <?php require_once 'google-api-php-client/src/Google_Client.php'; require_once 'google-api-php-client/src/contrib/Google_DriveService.php'; require_once "google-api-php-client/src/contrib/Google_Oauth2Service.php"; $scopes = array('https://www.googleapis.com/auth/drive'); $accountEmail = 'SECRET'; $accountP12FilePath = './key.p12'; $key = file_get_contents($accountP12FilePath);...

How to return RSA key in jwks_uri endpoint for OpenID Connect Discovery


python,google-oauth,jwt,openid-connect,openid-provider
Working on the discovery part of an OpenID Connect provider, I'm a bit confused about how to properly return my public keys. My problem is specifically with the modulus (n) and the exponent (e) values. The initial values of both are: n =...

Need clarification on email_verified field of ID Token


google-api,google-oauth,google-openid
I'm using Google's OpenID Connect service to authenticate users. I was considering rejecting all accounts if the email_verified field was false, but I don't see a real world scenario where someone will hit my system with this field set to false. The first time you log in to Google the...