Google Fit on Android is working on debug but not on production - google-fit

I am using History API to get user steps. It's working on debug but not on production.
I had created two certificates on OAuth 2.0 Client for both debug and production apps.
Unfortunately, I can get the steps in debug app, but not in the production signed app.
The app is not published for public yet. It's still in the internal testing. It's of course signed with production key.
When running the app, it shows Google authentication dialog so users can select Google account to be used for authentication. Upon selecting account, it shows error:
com.google.android.gms.common.api.ApiException: 4: The user must be signed in to make this API call.
Any help please?

Hopefully ✓this answer saved my time.
Basically, when your app using "App Signing", you need to check the SHA1 used by "App Signing", not the one mentioned on the official Google Fit documentation as release certificate.

Related

Using Gmail API in Chrome Extension without Identity API?

I have a Chrome extension that uses the Gmail REST API to send emails on behalf of the user. This API requires an Oauth2 token, which I'm retrieving using chrome.identity.getAuthToken.
The Problem
However, I am running into some issues with the Chrome Identity API. In particular, if the user authenticates with chrome.identity with a different Gmail account then the one they're signed into Chrome with, then they are prompted to re-login every hour or so (which doesn't happen if the accounts are the same). In addition, I'd like to minimize the number of permissions my extension asks for as a general principle (permissions sometimes introduce warning messages on install and risk disabling existing users on update), so I'd like to not have to ask for the "identity" permission if I can avoid it.
My Question
How can I authenticate the Gmail API in Chrome Extensions without using the Identity API?
Current Progress
I initially tried using Google's Javascript Client for auth, but that seems to be incompatible with Chrome extensions. After having searched other SO issues and some Google materials, it seems that the Identity API is indeed the recommended auth solution in Chrome Extensions. However, for the UX reasons mentioned above, I'm finding this solution problematic. And I do think an alternative should be possible -- for example, the MixMax Chrome extension, which uses the Gmail API, does not ask for the Identity permission.
Any help would be much appreciated! Thanks!

GCP project created by an app authorized by me, but I do not have access to it?

I'm developing some automation/integration between a CRM software and my google account. I am attempting to use the Google Apps Script API so I can remotely execute functions in Google Apps Script through the integration I'm building from within the CRM software.
The only problem is, when attempting to run a function which calls a GAS function through the API, I get the following error:
"Apps Script API has not been used in project project number before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/script.googleapis.com/overview?project=103424032563 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
This would normally be no problem, as I would simply access the GCP portal through the link and enable the GAS API, but when I try to access my project, I don't have access at all, and get the "failed to load data" error.
Further complicating my issue, GCP support will not help because they suspect I am a hacker trying to obtain access to a project that, for all they know, isn't mine.
And because I cannot access this project to authorize the API, I also cannot associate my google script with the same project, as this is a requirement for the Google Apps Script API to function.
I suspect it's the CRM software piece in which I'm developing this integration that is causing this error, (somehow the GCP project is being created by a different user,) but they haven't been all that helpful in determining what's going on.
Have any of you had a similar situation? And, if so, how did you approach solving it?
Further complicating my issue, GCP support will not help because they
suspect I am a hacker trying to obtain access to a project that, for
all they know, isn't mine.
Google Support does not refuse to help. They don't accuse you of being a hacker. Google Support can look at the project and see if you have credentials in the project and if you do they can explain how to authorize yourself. However, Google Support requires a support agreement, which is not free. If you do not have one, then you are not entitled to technical support only billing support. Look up your billing account ID and send a request for billing support. Your billing account will also show you which projects are linked to your billing account.
The issue is that you are trying to access the wrong Project ID. Figure out what is the correct Project ID. If you have the Cloud SDK installed execute this command gcloud projects list and this will tell you which projects your credentials have access to.

Bot stopped responding, no errors logged

I had a bot working. It pulled data based on a keyword search from a spreadsheet. It suddenly stopped working - with no changes to the code - and is not logging any events in onMessage, onAddToSpace or onRemoveFromSpace.
Sending a DM to the bot responds with "Bot not responding". I have check the Cloud Console and it is published to my account with the correct ID. All fields in the console match settings in the bot headers. Nothing is logged to StackDriver.
I also had a webapp deployed with the bot, and it was working concurrently. I disabled the web app to no results.
The most confounding issue is that other bots deployed are still working. What am I missing?
UPDATE
I went through all of the API scopes I needed. I was pulling from DriveApp and the YouTube data API. Disabling the YouTube API has allowed the app to start working again.
UPDATE 2
Porting the code to a separate working bot allowed the YouTube API to begin working again. The other project was also serving a web app, but disabling the app didn't make any change. I think there is some kind of permissions conflict when a single script is serving multiple resources. Perhaps the chat bot uses a hidden URL that is in conflict with a hosted web app. I cannot find any documentation about how the chatbot is served from apps script other than the deployment ID. Is there another piece to the puzzle?

Access to Web App

I have to write a small reservation web app to be used inside the company where I work. I decided to try out Google Apps Script (GAS). In short, the user must be able to select any equipment in a list and submit it along with a date he's planning to use it and his identification (this small system must implement the complete CRUD).
The environment:
Google Spreadsheet as a database
Interface made with GAS published as a Web App
The app will be accessible just to members of the company's domain, but I'm developing it in my personal account for now.
In the development environment, everything works fine. Then I deploy it as web app the project (Execute app as: Me; Who has access to the app: anyone). When anyone acess the link, I can't retrieve the user information (Session.getActiveUser().getEmail()). It always retrive the developer information (my information). If I switch the "Execute app as" to "User accessing the app", then the app can't access the spreadsheet that is making the role of the database. In the development environment this works fine.
The rest of the web app is working fine. I just wanted to get and record the identity (email) of who made de reservation in an automatic way (not by asking the user to type this information).
Do I have to setup something else before people can access it?
Thanks in advance.
[EDIT 1]: The situation changed a little bit. I made a few more tests and it seems that the deployed web app get updated just when I save it as a new version in the project. Anyway, I still can't retrieve the active user email. The Session.getActiveUser().getEmail() now returns a blank string.
[EDIT 2]: Following Sujay Phadke's answer bellow, I tried migrating the web app to the company's environment. It worked like a charm.
Juliano
It's well documented here: getActiveUser
When the webapp permissions are set as "execute as me", it seems that the returned userid string will be empty. It also depends on your specific domain permissions as mentioned there.

I am facing "The authenticated user has not installed the app with client id" error even after installing the app [duplicate]

I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error:
"The authenticated user has not installed the app with client id ..."
Reading further, it seems I need to publish my Emacs application in the Chrome Web Store to get access to the Drive API. That doesn't make sense to me...I noticed that there is a FUSE project in development for Google Drive, which suggests that native development is possible. When I skimmed the code, however, I didn't see a Chrome Web Store component to getting it working.
Am I trying to misuse the API, or is there an route to make this work that makes more sense?
EDIT:
According to Ali Afshar, of the Google Drive team, installation is no longer required to use this API. So what follows may no longer be relevant, but will be left for historical purposes.
So, first off the API does not support application development in the sense that we are both doing it, I wouldn't use the word native though. The good news is I have been doing some research and Google Drive is really just a rebranding of Google Docs. So the Google Docs API could be a good choice as well for the same purposes.
Anyway, here's the steps to solve the error: "The authenticated user has not installed the app with client id ..." Which is a 403 error, for the sake of this answer. These steps assume you have set up an app in the chrome web store as is required, and installed it. I am working on my local machine too, with my project: http://github.com/tom-dignan/gdrive-cli which I have gotten past this error, so I think you should keep plugging away at your emacs version, because I think we can make this work.
a. Open the Google APIs console.
b. Confirm you've already enabled the apis under "API Access" both the API and SDK for Google drive should be enabled. There you get your client secrets/api keys and such. I am almost positive you've done this already, so go ahead to C. (this is here for others who may have missed it)
c. In the left navigation bar, under "Drive SDK" you will need to do the following:
Add a "Support URL" (required)
Add at least a small 16x16 application icon (required)
Add "OAuth Client ID (Required)" under Drive Integration (I was just tinkering and this seems to be the key field.)
Add "Open URL (Required) URL to open for your app from the google drive UI."
Check off "Multiple File Support"
Add some MIME types and file extensions, "text/plain", and txt for example
Add the the auth scopes:
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
Don't bother trying to add the auth scopes for Google Docs here, because it won't work. Google does not want us to use it that way because files that drive apps create should be private to that app. Integration with Google Docs will have to be separate.
Now I know you must be thinking "why do I have to add some of these..." It's because the form makes them required fields. In mine, I put a couple URLs that point to static HTML pages.
Once you've done the above, clean up your state and reinstall your chrome app. Then try your code again, and it should stop giving you a 403.