Google drive dredit example - google-drive-api

I can't run the of dredit example for PHP, as you can see here i can't grant access to the app, always do a redirect to auth:
http://drivecrypt.sofistic.net
any suggestions?
thanks

Did you follow all setup steps listed at https://developers.google.com/drive/examples/php#setting_up_this_sample_application?
More specifically, did you register your app (step 2) and create a listing for it on the Chrome webstore (step 3)?

I change access_type=online to access_type=offline and all work again.

Related

Clasp Could not read API credentials. Are you logged in globally?

I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps

Error:Exception: You do not have permission to call Session.getActiveUser. Required permissions: https://www.googleapis.com/auth/userinfo.email

I recently migrated one of my projects to the new V8 engine of appscript.I am getting this exception
Exception: You do not have permission to call Session.getActiveUser.
Required permissions:
https://www.googleapis.com/auth/userinfo.email..Session.getActiveUser
is not accessible without permission
Any ideas would be appreciated
As stated by #zimday this isssue has been already reported in Google Issue Tracker.
You can follow the issue in this link. Give it a +1 to make Google aware of the people affected by it.
As stated by #Raserhin, there's an open issue with google and the problem seems to be with the new App Script runtime powered by Chrome v8.
A small workaround (until the issue is resolved) will be to disable the App Script runtime as follows: (Run -> Disable App Script runtime powered by Chrome V8). The project will now run with Apps Script Legacy which does not have this issue.

upload fail the google api after redirecting to localhost

After I run the following code from:
https://developers.google.com/drive/api/v3/quickstart/python
I get the link:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=792377765624-8l03cnfmj1km5gd27227kuaem37okdip.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A41245%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&state=8xHuMrgWMisZa7Hww6HpIZrRdkRTjq&access_type=offline
I click it and get new pages.
I was not allowed to upload pictures here,sorry.
Because my score is low in stackoverflow
Finally, it tell me I can not connect to:
http://localhost:44637
Screenshots of the behaviour: https://blog.csdn.net/appleyuchi/article/details/102940981
According to the screenshots you provided and the url you are getting redirected to, the problem is that the Google account with which you downloaded the credentials file is not the same as the one with which you grant authorization to Drive. Both should be the same, because the credentials file contains information that identifies the account that downloaded them.
Check these for further information on the authentication process:
https://developers.google.com/identity/protocols/OAuth2
https://developers.google.com/identity/protocols/OAuth2WebServer

Reauthenticate or Remove authentication Pydrive during runtime in Google Colab

I want to reauthenticate my Google Drive Credentials so that I can login from a different Google account and access it using pydrive. How can I do that?
I am using the following code to authenticate:
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(auth = gauth)
I want to get a fresh token and option to login again into a different google account?
Thanks for helping!
Try deleting the credential file produced by auth.authenticate_user() based on the auth module
rm /content/adc.json
I have just found a solution to this issue. If one goes to his/hers Google Account Settings->Security->Signing in to other sites(all the way down)->YOUR PROCESS NAME and then simply remove it. If you try simply listing the files in the authenticated drive again it should fail with "Token has been expired or revoked."
Just make sure when you create and enter your correct account credentials to delete the credentials/client_secret.json file as the settings.yaml does not seem to overwrite
To reset credentials just remove the gdrive config folder with a shell command from a code block
rm ~/.config/Google/DriveFS/ -rf
I ran into a similar problem where I clicked on the wrong account for Google Drive authentication. None of the files I needed to access were available, and I couldn't figure out a way to revoke a token by the comments above. I tried both restarting the runtime and changing from GPU to TPU. When I tried the latter, it worked and the authorization prompt returned. However, I'm not sure if it worked or just reached the token refresh time.
I factory reset my runtime and was able to get it to accept a different credential.
Runtime -> factory reset runtime

Google Drive Open URL development workaround

it's possible to setup a Open URL for MIME type support at (console.developer.google.com). That's create and works fine for my application. But only for the product instance at Google Cloud. In detail:
I've released my application in version 1. It's AppEngine base and it supports a Open URL myapp.appspot.com/oauth2callback. So after the release I will going on with feature development for version 2. I use the local AppEngine dev setup. So I take my second client ID and change the Open URL to my local workstation mydev.workstation.com:8080/oauth2callback. That works fine, but it breaks my product instance. Is there any workaround to use Open URL for the production instance and a second Open URL for my dev instance? In my opinion the Drive SDK settings should be:
enable Authentication Production:
Client ID: xxx
Additional Scopes:
Install URL:
Open URL: https://myapp.appspot.com/oauth2callback
enable Authentication Development:
Client ID: xxx
Additional Scopes:
Install URL:
Open URL: http://devworkstation.com:8080/oauth2callback
Jens
Create separate projects in the console for prod/qa/dev
The answer from #SteveBazyl is the preferred one for all the reasons stated. A kludgy alternative would be to have the servlet that is bound to the Open URL detect when it is dealing with a test scenario and do a 301 redirect to your dev server.
Also, the API URL is pretty consistent, so once you've sniffed it once, it's not to difficult to path the host and use it in a curl script or browser bookmark for local testing.
As an aside "oauth2callback" is a slightly odd name for your Drive Open URL. It's not wrong, but "driveopen" would show the separate concerns.