Suddenly, gdrive command line tool stops working, and always gives the following error message:
Failed to get about: Get https://www.googleapis.com/drive/v3/about?alt=json&fields=maxImportSizes%2CmaxUploadSize%2CstorageQuota%2Cuser: oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Bad Request"
}
This is because your authorization token has expired.
Currently there is an open Issue to improve this error message here.
You should delete your token with rm ~/.gdrive/token_v*.json
then run the gdrive about command to reauthorize
The steps I fixed it:
rm ~/.gdrive/token_v2.json as other answer suggested.
But I get danger error if I open the link get from gdrive about to re-authorize:
So I create a drive project by go to https://developers.google.com/drive/api/v3/quickstart/js and click "Enable the Drive API":
Click the "API Console" link on that dialog:
To make default redirect url (i.e. urn:ietf:wg:oauth:2.0:oob) works, we need Installed type app and can't use "Web application type app"(which only allow http/https scheme). So click "Create credentials" and choose "Oauth client ID" item:
Ensure select "Other" type:
Copy "Client ID" and "Client secret" from created item. cd to ~/.go/src/github.com/prasmussen/gdrive/, then replace both at this two variables in handlers_drive.go file, save it, e.g.:
const ClientId = "xxx.apps.googleusercontent.com"
const ClientSecret = "xxx"
Then run go install at that directory. Now run gdrive about and open that link in web browser. I get This app isn't verified error page. You are the author who created that app on above steps and suppose safe. Nevertheless simply click "Advanced" link and click Go to Quickstart (unsafe) link:
Click "Allow" it, copy/paste the code back to gdrive about and done:
Managed to resolve this by retriggering gcloud authorization with:
gcloud auth application-default login
Related
I am a beginner trying to log in to McMaster-Carr API. I have a .pfx authentication file, an API password, and my main login/password (email/account password). I have imported the .json file into postman and have inputted my main login credentials in the fields below, but I am not getting a success output message. I am confused as to where the API key/password goes and where I upload the .pfx file as well.
McMaster-Carr API: https://www.mcmaster.com/help/api/
How to upload .pfx file to Postman application
[ Windows / Linux ] - Select File > Settings > Certificates
[ Mac ] - Select Postman > Preferences > Certificates
On the Client Certificates section, select the Add Certificate link
Add the hostname domain of the API service: api.mcmaster.com
Upload the .pfx file
Add the passphrase for the .pfx file: API password
Select Add (details should appear as below)
Close the screen and try to log in again with the same request
I have written a Java application using Google's SDK v3 and Java 8 to download binary files from Google Drive (not Google doc or sheets or anything like - binary files I uploaded there). My app has no trouble listing the files, but when I try to download one I get a permissions error:
Exception in thread "main" com.google.api.client.http.HttpResponseException: 403 Forbidden
{
"error": {
"errors": [
{
"domain": "global",
"reason": "appNotAuthorizedToFile",
"message": "The user has not granted the app 38578455738 read access to the file 1acfVsq9dUUYuk6q9gM69aWVasvdfr.",
"locationType": "header",
"location": "Authorization"
}
],
"code": 403,
"message": "The user has not granted the app 38578455738 read access to the file 1acfVsq9dUUYuk6q9gM69aWVasvdfr."
}
}
The code that attempts to download is:
String fileId = "1acfVsq9dUUYuk6q9gM69aWVasvdfr";
OutputStream outStream = new ByteArrayOutputStream();
service.files().get(fileId).executeMediaAndDownloadTo(outStream);
My questions are:
How do I know that my app is 38578455738?
How do I grant it (or anyone) permission to download?
I have tried using the Google Drive web interface to share with "anyone" but that didn't help.
Service accounts are not you. Think of a service account as a dummy user. It has its on Google drive account, Google calendar account and probably a few more.
The good thing with service accounts is they can be preauthorized this makes them be idea for use with server to server communication like cron jobs.
Exception in thread "main" com.google.api.client.http.HttpResponseException: 403 Forbidden
{
"error": {
"errors": [
{
"domain": "global",
"reason": "appNotAuthorizedToFile",
"message": "The user has not granted the app 38578455738 read access to the file 1acfVsq9dUUYuk6q9gM69aWVasvdfr.",
"locationType": "header",
"location": "Authorization"
}
],
"code": 403,
"message": "The user has not granted the app 38578455738 read access to the file 1acfVsq9dUUYuk6q9gM69aWVasvdfr."
}
}
Means exactly that. The user who owns the file 1acfVsq9dUUYuk6q9gM69aWVasvdfr has not granted the application 38578455738 access to their data.
IMO this error message is a little miss leading this is why i have asked you to post your authentication code. The way the error message reads makes me think that the currently authenticated user is not the service account and that this user has not gone though the consent process.
However if you are currently logged in as the service account. Its actually the service account user who does not have access (this assumes that your using service account authentication code when you are logging in to download the file. ). Then in order for the service account to access the file. The user who owns it must share the file with the service account. To do that take the service account email address go to the Google drive website find the fine in question and share the file with the service account. Give it read or write access which ever it needs. The service account should then have access to the file.
You know that your app is 38578455738 because you register your application in the Google API Console.
You authorize your app using OAuth 2.0, with the user granting Google a scope of access that includes download, such as https://www.googleapis.com/auth/drive.readonly
Relevant links:
About Authorization -
https://developers.google.com/drive/api/v3/about-auth
Setting up API Keys -
https://support.google.com/googleapi/answer/6158862?hl=en
When I try to run the Polymer Shop locally, both the bundled and unbundled builds, using the SimpleHTTP2Server , on my local host using port 5000, the request for service-worker.js fails:
An SSL certificate error occurred when fetching the script.
https://localhost:5000/service-worker.js Failed to load resource: net::ERR_INSECURE_RESPONSE
(index):1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.
Is there an easy way to get this to work? I tried a number of start up flags, like:
chrome.exe --ignore-certificate-errors --incognito
--unsafely-treat-insecure-origin-as-secure --allow-insecure-localhost
but that didn't help, I still get:
(index):1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.
Following alesc's suggestion, I found instructions here:
These are instructions for Chrome 55 on Windows 10. It seems these steps may change frequently.
On the page with the untrusted certificate (https:// is crossed out in red), click the lock so a popup opens up.
Click the Details link under the information section at the top.
Click on the View Certificate button.
Click on the Details tab
Click on the Copy to File
Click Next
Export as PKCS #7
Open up Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates
Import the certificate created in step 7 to both the Intermediate Certificate Authorities tab as well as the Trusted Authorities Tab.
Restart Chrome and open your localhost site.
Having issues with setting up yii2 basic framework and ibm bluemix.
I was using this link as a guide: https://github.com/Twanawebtech/yii2App-Bluemix/blob/master/README.md
Step 1a: clone the code and setup
Open your terminal
$ git clone https://github.com/Twanawebtech/yii2App-Bluemix.git
$ cd yii2App-Bluemix
Step 1b: Set cookie validation key in config/web.php file to some random secret string:
'request' => [
// !!! insert a secret key in the following (if it is empty)
- this is required by cookie validation
'cookieValidationKey' => '<secret random string goes here>',
],
Step 1c: You can then access the application through the following URL:
http://localhost/yii2App-Bluemix/web
you should see the Congratulations Screen
Step 1d: Manifest
Go back to the yii2App-Bluemix folder
and open the manifest file
rename name and host to the name you want to call it.
Go to the command prompt and using cloud Foundary CLI (once you have setup cloud Foundary CLI)
enter cf login
API endpoint: https://api.ng.bluemix.net
enter Email Address:
enter Password:
Select a space (if you have more than one space allocated)
Step 2: Push your code to Bluemix
$ cf push yii2App-Bluemix -b https://github.com/cloudfoundry/php-buildpack.git -s cflinuxfs2
Step 3: Access your app by entering the following URL into your browser:
http://yii2basic.mybluemix.net/yii
However I don't get the congratulations screen but instead I get the following which is the source code of the index.php file found in the web folder
What am I missing or forgot to do???
I am implementing yii2 authclient, I created the client id in in google api console this is the redirect url I created in gogle console with the corresponding client id.
http://mysite.x10host.com/oauth2callback
when I access my site login this is how it looks like
http://mysite.x10host.com/home/mysitex/public_html/web/site/login
when I click the the google icon
That’s an error.
Error: redirect_uri_mismatch
Application: Project Default Service Account
You can email the developer of this application at: myemail#gmail.com
The redirect URI in the request: http://mysite.x10host/home/mysitex/public_html/web/site/auth?authclient=google
can someone help me on this.
Thank you in advance