I am using Session.getActiveUser().getUserLoginId() to fetch the current user's email id but other than creator of the spreadsheet it is returning empty string. I have also used getEffetiveUser() but no hopes.
I will be appreciate if i could get some suggestions on this.
Many Thanks in advance.
Regards,
Chetan
Quote from the Google documentation:
If security policies do not allow access to the user's identity, User.getEmail() returns a blank string
Note that User in the above code is a sort of "placeholder" for the "User" class, which the Session.getActiveUser() returns.
If your script is set to:
web app deployed to "execute as me"
You can not get the user email.
So, the one thing I can tell you for sure, is that your code does not have permission to get the user info. I can't tell you why, because I don't know the conditions and settings under which your code is running.
Link to Google Documentation for getActiveUser method
Related
I'm brand new to wrangling the IG Graph (and to API's, in general) and hoping someone might be willing to lend a hand. A bit of context: I am building a SaaS on Bubble.io. I have my authentication set up and am in the process of developing my FB App. In short, I want to enable the following:
Auth'd users curate content on IG by #mentioning my app's account in a comment to a post.
Those comments are intercepted via web hook (currently running smoothly on Integromat).
They payload is then passed to an API Workflow on Bubble, which parses the comment ID
The workflow then retrieves details of the comment and associated post.
The comment is correlated with the appropriate app user based on the username of the comment's owner.
The final two steps is where I'm confused. Based on my reading of FB's documentation, it seems impossible to retrieve a username or user id for the owner of a mentioned comment, which clearly presents a problem for me. Is this the case or am I just missing something? It seems to me there should be a way of getting at this data.
enter image description here
You can use the username field, as done followingly:
mentioned_comment.comment_id(COMMENT_ID){media,text,username}
Context:
I'm writing a webapp in GAS in order to help sales to find specific mails for GDPR.
it's a sort of mail filters, with some research templates, that returns specific mails of the user's mailbox, then he can delete it, or consult it
Issue:
I'm trying to find a way to open gmail onto the specific mail that is previoused on my webapp.
As I said just above, for a given mail , the user can delete it (This is ok), or open it in gmail to consult the whole thread before deletion. That's the "open" part I don't know how to work with.
Id like to use the UrlFetchApp, and create the URL with the mail.
I'm able to get the id of the mail, but the id isn't the same when you are on gmail. I suppose it's a mix between the id of the mail and the session token. But how may i recreate it ?
Maybe there is a function to do so I haven't find yet ?
Any clues ? :)
Thanks to Kessy, i've outpassed my first impression, tried to enter
https://mail.google.com/mail/u/0/#inbox/[id], and it worked (you're then redirected to the correct URL, the one i talked about, but who cares about that).
So there is no issue... The solution is to use the ID anyway.
I don't even know if this question should be deleted or not.
What is the best-supported approach for tracking logged-in Usernames/Ids in App Insights telemetry?
A User with Username "JonTester1" said some Pages he visited 4 hours ago were really slow. How can I see everything JonTester1 did in App Insights to trouble shoot/know which pages he's referring to?
Seems like User Id in App Insights is some Azure-generated anonymized thing like u7gbh that Azure ties to its own idea of the same user (thru cookie?). It doesn't know about our app's usernames at all.
I've also seen a separate field in App Insights called Auth Id (or user_AuthenticatedId in some spots), which looks to sometimes have the actual username e.g. "JonTester1" filled in - but not always... And while I don't see any mention of this field in the docs, it seems promising. How is our app's code/config supposed to be setting that Auth Id to make sure every App Insights log/telemetry has it set?
Relevant MS docs:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/usage-send-user-context
This looks to just copy one library Telemetry object's User Id into another... no mention of our custom, helpful Username/Id anyway... and most in-the-wild examples I see don't actually look like this, including MS docs own examples in the 3rd link below; they instead hardcode get a new TelemetryClient()
https://learn.microsoft.com/en-us/azure/azure-monitor/app/website-monitoring No mention of consistently tracking a custom Username/Id
https://learn.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics#authenticated-users Shows some different helpful pieces, but still no full example. E.g. it says with only the setAuth... JS function call (still no full example of working client-side JS that tracks User) on the page, you don't need any server-side code for it to track custom User Id across both client-side and server-side telemetry sent to Azure... yet then it also shows explicit code to new up a TelemetryClient() server-side to track User Id (in the Global.asax.cs or where?)... so you do need both?
Similar SO questions, but don't connect the dots/show a full solution:
Azure Insights telemetry not showing Auth ID on all transactions
Application Insights - Tracking user and session across schemas
How is Application insight tracking the User_Id?
Display user ID in the metrics of application Insight
I'm hoping this question and answers can get this more ironed out; hopefully do a better job of documentation than the relevant MS docs...
The first link in your question lists the answer. What it does show you is how to write a custom telemetry initializer. Such an initializer lets you add or overwrite properties that will be send along any telemetry that is being send to App Insights.
Once you add it to the configuration, either in code or the config file (see the docs mentioned earlier in the answer) it will do its work without you needing to create special instances of TelemetryClient. That is why this text of you does not make sense to me:
[…] and most in-the-wild examples I see don't actually look like this, including MS docs own examples in the 3rd link below; they instead hardcode get a new TelemetryClient()
You can either overwrite the value of UserId or overwrite AuthenticatedUserId in your initializer. You can modify the code given in the docs like this:
if (requestTelemetry != null && !string.IsNullOrEmpty(requestTelemetry.Context.User.Id) &&
(string.IsNullOrEmpty(telemetry.Context.User.Id) || string.IsNullOrEmpty(telemetry.Context.Session.Id)))
{
// Set the user id on the Application Insights telemetry item.
telemetry.Context.User.AuthenticatedUserId = HttpContext.Current.User.Identity.Name;
}
You can then see the Auth Id and User Id by going to your AI resource -> Search and click an item. Make sure to press "Show All" first, otherwise the field is not displayed.
Auth Id in the screenshot below is set to the user id from the database in our example:
We access the server from azure functions as well so we set the user id server side as well since there is no client involved in such scenarios.
There is no harm in settting it in both places, javascript and server side via an initializer. That way you cover all scenario's.
You can also manually add user id to app insights by
appInsights.setAuthenticatedUserContext(userId);
See App Insights Authenticated users
As part of our flutter app -- we ask the user to enter their Discord username#tag .. we do NOT ask them to login to Discord nor is there any need to per se..
However, we do want to check to make sure what they entered is at least valid and defined in Discord. I am having a hard time finding any method to just validate that the username#tag exists ..
Is there such an API call (I've read the docs a few times but nothing is leaping out at me to see if we can just check if this exists without trying to login)?
Thanks!
Short said: No, it is not possible.
You need an ID to verify the existence, but it is better to go for Full OAuth so you can verify that your User is not a fraud.
I have a Google Spreadsheet containing a script that I wrote. The script updates a per-person sheet named after the logged in user, or creates a new one if it's not there yet.
I shared it in "can edit" mode with other people, expecting the code accessing the user name to work as it did in my case, but apparently it doesn't.
Google Apps Script seems to contain three ways to get the name of the current user:
Session.getActiveUser()
Session.getEffectiveUser()
Session.getUser()
and all of them return the empty string when I'm not the user running the script.
(Btw I'm having a hard time to tell the difference between them...)
Considering that I'm sharing this spreadsheet in read/write mode, I would be a bit surprised if this was an intended security method... it's not like I don't know the emails of the people accessing the spreadsheet I've explicitly shared with them... Plus, Google is asking for permission anyway, couldn't it ask for permission to access the user name as well??
Is there a way around this?
Is there a way around this?
These methods only work if you're using a Google Apps account and you're on the same domain as the user. If not, then there's no way to get the user id. AFAIK Google removed this feature completely for regular accounts. You may try to argue with them opening an issue here.