Prompt shared users to install app - google-drive-api

I'm using the Google Drive SDK and I made a simple app with a sharing feature. Unfortunately, when a document is shared with a user who doesn't have my app installed, they are prompted with the following message:
You do not have StoryPad installed
This item was created with StoryPad, a Google Drive app you have not installed.
However they don't see a link or an option to install this app. Is there a way to configure it so that they are prompted to install on this screen? I don't want users to have to hunt around looking for a way to install this app because they will leave.
Here is a screenshot of how it looks:

Looking at the Google Drive SDK documentation, in the error handling section, it seems if you trap the error:
`403: The authenticated user has not installed the app with client id {clientId}
The user has not installed the requesting app, or has uninstalled it.`
The documented suggested action is to:
Direct the user to the Chrome Web Store to install the app.
You don't list which language you're working with, so an example (other languages are listed on the above referenced page as well) in JavaScript could be:
request.execute(function(resp) {
if (!resp.error) {
//Excellent, everything is working correctly! Proceed to show your file.
} else {
console.log('Error code: ' + resp.error.code);
if (resp.error.reason == "appNotInstalled") {
//Here is where you implement the action to inform the user where to download your app.
alert("You need to install StoryBoard to view this file! Please proceed here: http://<link to your app>");
}
// More error information can be retrieved with resp.error.errors.
}
});

Related

Firefox add-on's native application runs only once

I have published a native messaging add-on on Mozilla, but the native messaging host (native app) runs only once, if I restart firefox, the native app does not start.
Here is the scenario:
Step 1: I install the native app on Windows 10 using the setup file, the setup also configures the registry key under
HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts
HKEY_LOCAL_MACHINE\Software\Mozilla\NativeMessagingHosts\
Step 2: Start firefox, download and install the public released (signed) add-on from mozilla. The add-on icon shows on Firefox, I click the icon, the add-on popup page shows, click the menu items on the popup, the add-on works as expected, the native app works too, it receives messages from add-on, and sends messages back to the add-on.
All is OK, it seems the native messaging add-on works well. However, after I restart firefox, click the add-on icon, click the menu items on the popup menu, nothing happens. I type about:debugging, in the console window, there is error message "Unchecked lastError value: Error: port is null".
This error only happens while using the signed add-on, using local version un-signed addon, the native messaging host and add-on always run, no such problem.
I want to know, when download and install the addon from Mozilla, except the addon's XPI file, are there other files also downloaded? Maybe these other files run after firefox restarts, and these files or their configuration prevent the native app from running.
Here is the code snippet in background page:
function connectToNativeHost()
{
var nativeHostName = “com.some-company.test”;
port = chrome.runtime.connectNative(nativeHostName);
console.log(port)
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
}
function onDisconnected()
{
console.log(chrome.runtime.lastError);
console.log(‘disconnected from native app.’);
port = null;
}
I test again and again, I find that after firefox restarts, the native app never runs again, firefox does not create a process for the native app.
Thank you for your help!

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

Programmatically installing a chrome extension to the default profile [duplicate]

I've written an extension for Google Chrome that will be released with the next version of our product. I want to understand what properties, paths for extraction, registry entries, etc. should I provide the installer of my product so that the end user doesn't have to install the extension on their own manually, and the installer does the complete job of installing the extension, and also notifies the user that the extension has been installed. As of now, the code that I have written is placed in a folder, and I use the "Load Unpackaged Extension" to load the extension. What should I do to achieve the aforementioned task?
Google's current policy on installing extensions via the registry (for Windows machines) is this:
Only extensions from the Google Extension Gallery (or Chrome Web Store - CWS) can be installed via the registry.
See this link - https://developer.chrome.com/extensions/external_extensions - for information on how this can be done. Keep in mind the following:
-This technique will still pop-up a msgbox to the user. its not completely silent.
-When using this technique, if the user subsequently removes the extension from her Chrome, the extension gets "blacklisted" on that chrome and will not re-auto-install until the user re-install it
manually. refer to Auto-installing a google chrome extension won't work ! for details.
Chrome has a couple ways of installing extensions programmatically:
http://www.chromium.org/administrators/pre-installed-extensions
Edit: yes, this policy has changed by now, as FuzzyAmi points out.
If you're using GNU/Linux, this is how you pre-install an extension from the chrome web store for all users:
/etc/chromium/policies/managed/yourextension_policy.json
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
{
"ExtensionInstallForcelist": [
"yourextensionuniqueidentifiersup;https://clients2.google.com/service/update2/crx",
"yourextensionuniqueidentifiersup"
]
}
Reference
metamask-chrome - AUR

Install firefox os apps available on Marketplace using App Manager

I am trying to install App using App Manager in Firefox OS device. But my problem is I am unable to push any of the apps which are published on MarketPlace. It show that
The webapp manifest isn't a valid JSON file: SyntaxError: JSON.parse:
unexpected character at line 1 column 1 of the JSON data at:
https://marketplace.firefox.com/app/pacman-canvas can't be opened
So can anyone suggest some way to push the app to my device using App Manager only?
It's pretty easy. On the Marketplace page (in Firefox desktop) open the marketplace page for the app. Then open Devtools and select the Debugger. In the debugger, break in file iframe-installer.html, on this line:
installPackage(e);
Now click the 'Free' button, the debugger will break on this line. In the console you now type:
e.data.data.product.manifest_url
This will give you a URL. If the URL is located at someone else's webserver (like Pacman), e.g. http://pacman.platzh1rsch.ch/pacman-canvas.webapp, you can (in the App Manager) click 'Add hosted app' and paste the URL. However you will need internet on the phone the first time you use the app (because its hosted app).
If the URL is a Mozilla URL (https://marketplace.firefox.com/app/etc.), you can open the link in your browser. Open the file. You now have a JSON file in which you need to look for the package_path key. F.e. for Recorder it's
"package_path": "https://marketplace.firefox.com/downloads/file/258677/recorder-1.1.zip"
You can now download this ZIP file, unzip it in a folder, and add the folder as a Packaged app.
For apps in the marketplace, you best solution for getting them on the phone is to just use the marketplace app. That said if you own the app in the marketplace you should be able to look at the manifest url of the app using the edit listing marketplace button. If this is a hosted app you can you use this manifest url in the add hosted app entry box within the app manager to add it and then push it to phone. On another note you can debug the system apps by using the procedure described here:
https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager#Debugging_Certified_Apps

How to install a Chrome extension programmatically?

I've written an extension for Google Chrome that will be released with the next version of our product. I want to understand what properties, paths for extraction, registry entries, etc. should I provide the installer of my product so that the end user doesn't have to install the extension on their own manually, and the installer does the complete job of installing the extension, and also notifies the user that the extension has been installed. As of now, the code that I have written is placed in a folder, and I use the "Load Unpackaged Extension" to load the extension. What should I do to achieve the aforementioned task?
Google's current policy on installing extensions via the registry (for Windows machines) is this:
Only extensions from the Google Extension Gallery (or Chrome Web Store - CWS) can be installed via the registry.
See this link - https://developer.chrome.com/extensions/external_extensions - for information on how this can be done. Keep in mind the following:
-This technique will still pop-up a msgbox to the user. its not completely silent.
-When using this technique, if the user subsequently removes the extension from her Chrome, the extension gets "blacklisted" on that chrome and will not re-auto-install until the user re-install it
manually. refer to Auto-installing a google chrome extension won't work ! for details.
Chrome has a couple ways of installing extensions programmatically:
http://www.chromium.org/administrators/pre-installed-extensions
Edit: yes, this policy has changed by now, as FuzzyAmi points out.
If you're using GNU/Linux, this is how you pre-install an extension from the chrome web store for all users:
/etc/chromium/policies/managed/yourextension_policy.json
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
{
"ExtensionInstallForcelist": [
"yourextensionuniqueidentifiersup;https://clients2.google.com/service/update2/crx",
"yourextensionuniqueidentifiersup"
]
}
Reference
metamask-chrome - AUR