How to get Google reCAPTCHA v2 data-sitekey? - recaptcha

I have this code for my Google Chrome extension which solves reCAPTCHA automatically.
"use strict"
var sid = setInterval(function () {
if (window.location.href.match(/https:\/\/www.google.com\/recaptcha\/api\d\/anchor/) && $("#recaptcha-anchor div.recaptcha-checkbox-checkmark").length
&& $("#recaptcha-anchor div.recaptcha-checkbox-checkmark").is(':visible') && isScrolledIntoView($("#recaptcha-anchor div.recaptcha-checkbox-checkmark").get(0)))
{
var execute = true;
if (sessionStorage.getItem('accesstime'))
{
if (new Date().getTime() - sessionStorage.getItem('accesstime') < 7000)
{
execute = false;
}
}
if (execute)
{
$("#recaptcha-anchor div.recaptcha-checkbox-checkmark").click();
sessionStorage.setItem('accesstime', new Date().getTime());
}
clearInterval(sid);
}
}, 500);
My question is...
From the above code. How do I get the data-sitekey and page url?

I know this is old, but for people in same situation:
Use your account of Google(Gmail)
go to this link https://www.google.com/recaptcha/intro/v3beta.html
- use the button Myrecaptcha
- register a new site
- give a label "my site label"
- Choose the type of reCAPTCHA
- enter the domain for you want use the captcha
- check the Accept the reCAPTCHA Terms of Service.
- check or not the send alerts to owners
- Click "register"
That´s all when finish you will see intructions and your data-sitekey.

Related

Google API to discover third party app access

Google Admin Console allows us to manage third-party App Access Control for OAuth apps registered and used for SSO. Is there an API to discover this list?
You can use the Reports API, method activities.list.
You can try the following example with Apps Script, this script will retrieve the list of the third-party apps.
function appAccessControl() {
var eventName = {
"eventName": "authorize"
};
var appsList = [];
var response = AdminDirectory.Activities.list("all", "token", eventName);
for(var i=0; i< response.items.length; i++)
{
if(appsList.includes(response.items[i].events[0].parameters[1].value)==false)
{
appsList.push(response.items[i].events[0].parameters[1].value);
}
}
console.log(appsList);
}
Note: To run this script you need to add the "Admin SDK API" service in your Apps Script project, on the left side of the screen, click on the “+” next to “Services”, search for “Admin SDK API”, select "reports_v1" from "Version", and click “Add”.

addFileAttachmentAsync() is not functioning as expected on Outlook Desktop on Windows 10 machine

I am trying to add inline image to mail body through Outlook Add-in. It works fine in OWA but Desktop app fails to attach it inline, instead I get the image as a regular attachment, and broken image icon on email body.
I contacted Microsoft Devchat, they don't seem to able to repro it, I tried the code they sent me , and it behaves the same.
Here is the code:
function AttCallback(asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.log(asyncResult.error);
} else {
var szCID = asyncResult.asyncContext.UniqueName;
var szAddBodyData = "<p>Here's a cute bird!</p><br><div><img src='cid:" + szCID + "'></div><br>";
Office.context.mailbox.item.body.setSelectedDataAsync(
szAddBodyData,
{ coercionType: Office.CoercionType.Html });
console.log("Attachment added");
}
}
function insertAttachment() {
var szName = "cute_bird.png";
var options = { isInline: true, ContentId: szName, 'asyncContext': { UniqueName: szName } };
//var options = { asyncContext: null };
Office.context.mailbox.item.addFileAttachmentAsync(
"http://i.imgur.com/WJXklif.png",
szName,
options,
AttCallback);
}
Here is what is happening on my machine.
Note: As you can see from the code, by the time callback function gets hit, attachment was already added. However I do have inline property set to true.
Has anyone experienced it before? Any suggestions would be appreciated.
See from the documentation:
https://learn.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/outlook-requirement-set-1.5
that inline image addition support shipped with Outlook requirement set 1.5. You should specify this capability in your manifest.xml to ensure your add-in is only appearing in clients where it can work and not show up if it can't.

SaveAsync not working with outlook new webui

I have recently come across an issue with the new UI of outlook 365 which is in trial stage at the moment. In my outlook addin we are using saveAsync method of officeapi, I found that when we are in new UI, SaveAsync method return null instead of ItemID.
However same code works with the existing UI without any issue and works as expected.
Has somebody came across this issue or know if there is any plan to fix it.
This issue happens on calendar appointment on new ui and it consistently returns null.
here is the code snippet
callSaveAsync();
var callSaveAsync = function() {
office.context.mailbox.item.saveAsync(function(data) {
logMessage("saveAsync complete - call number " + asyncCount);
logMessage("ID returned: " + data.value);
if (data.value === null) {
asyncCount++;
setTimeout(function() {
callSaveAsync();
}, 2000);
} else {
logMessage("ID success.", true);
asyncCount = 1;
itemID = data.value;
callGetItem(itemID);
}
});
};

Is it possible to detect when a user opens the chat window on Facebook?

I'm trying to create a chatbot where in order to avoid the user opening the chat window and not knowing the available options, I want to give some basic instructions when the user opens the chat window.
Is there any trigger available when the user opens a chat window? Maybe then I can check, and if there's not an ongoing conversation I could provide basic instructions.
I did some googling and found nothing about this. Is it possible to do something like this, and if not, is there a way to mitigate this problem, and provide the user with information regarding the chatbot capabilities and supported instructions?
Facebook does not allow bots to initiate a conversation, unlike Skype or other platforms.
There are still some tricks you can do :
Go on the Settings of your Facebook page, then Messaging and check "Show a Messenger Greeting" as below, and write your greeting sentence.
The result will look like this :
You can also set a "Get Started" button to trigger an event.
Here's the doc :
"https://developers.facebook.com/docs/messenger-platform/thread-settings/get-started-button"
You can monitor for two event types: ConversationUpdate and ContactRelationUpdate.
The first one (ConversationUpdate) is called when a user is added or removed from the conversation. So, there's a place where you can introduce available options. It will be each type the new conversation has started. So, it may become annoying, you may add a check - do not show it if the user has been using the bot for some time.
The second (ContactRelationUpdate) is called when a user adds or removes the bot to/from the contacts. In general, it is only called once per user action.
Here's the extract from the Bot-Frameworks examples:
For Node.Js
bot.on('conversationUpdate', function (message) {
// Check for group conversations
if (message.address.conversation.isGroup) {
// Send a hello message when bot is added
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
var reply = new builder.Message()
.address(message.address)
.text("Hello everyone!");
bot.send(reply);
}
});
}
// Send a goodbye message when bot is removed
if (message.membersRemoved) {
message.membersRemoved.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
var reply = new builder.Message()
.address(message.address)
.text("Goodbye");
bot.send(reply);
}
});
}
}
});
bot.on('contactRelationUpdate', function (message) {
if (message.action === 'add') {
var name = message.user ? message.user.name : null;
var reply = new builder.Message()
.address(message.address)
.text("Hello %s... Thanks for adding me. Say 'hello' to see some great demos.", name || 'there');
bot.send(reply);
} else {
// delete their data
}
});
For C#
private void HandleMessage(Activity message)
{
if (message.Type == ActivityTypes.ConversationUpdate)
{
if (activity.MembersAdded.Any(m => m.Id == activity.Recipient.Id))
{
var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
var response = activity.CreateReply();
response.Text = "Hi! I am Bot. Here's what you can do...";
await connector.Conversations.ReplyToActivityAsync(response);
}
}
else if (message.Type == ActivityTypes.ContactRelationUpdate)
{
if (Activity.AsContactRelationUpdateActivity().Action == ContactRelationUpdateActionTypes.Add)
{
var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
var response = activity.CreateReply();
response.Text = "Hi! I am Bot. Thanks for adding me. Here's what you can do...";
}
}
return null;
}
I think the acid answer is not.
But you can intercept the IConversationUpdateActivity type message to know if the user has added the bot to a conversation. In the C# project template you can find a code block that ask for this message type but do nothing.

Authorization needed for classroom.profile.emails

I'm working on a web app in Google Apps Script, and I'm having some trouble understanding how the authorization is handled. When accessing the web app as the user using the app, it prompts for authorization, and everything appears okay. However, I'm call userProfiles.get and looking for student email addresses, and it returns the profile without the email.
function classRosters() {
var teacher = Classroom.UserProfiles.get(Session.getActiveUser().getEmail());
var classList = Classroom.Courses.list({teacherId: teacher.id}).courses;
var classes = [];
for (i in classList) {
if (classList[i].courseState != 'ACTIVE') {
continue;
}
var class = classList[i];
var classId = classList[i].id;
var className = classList[i].name;
classes.push([className]);
var teacherId = Classroom.Courses.Teachers.get(classId, classList[i].ownerId).userId;
var teacherEmail = Classroom.UserProfiles.get(teacherId);
var title = Classroom.Courses.get(classId).name;
var students = Classroom.Courses.Students.list(classId).students;
var studentArray = [];
if (students) {
for (j in students) {
var currStudent = students[j];
var email = Classroom.UserProfiles.get(currStudent.userId).emailAddress;
var email = Classroom.Courses.Students.get(classId, currStudent.userId).profile.emailAddress;
studentArray.push(email);
Logger.log(email);
}
}
for (j in classes) {
if (className.indexOf(classes[j]) > -1) {
var classIndex = +j;
classes[classIndex].push(studentArray);
}
}
}
return classes;
}
I've played with the API explorer, and it shows that classroom.profile.email is required, but that's not included in the scopes. When I use the API explorer, I can authorize, and it works, and my web app will work as well until the authorization from the explorer expires.
Is there any method to prompt for authorization in the GAS library for the Classroom advanced service? I can't find anything much that's specific to GAS and not part of the overall API.
Thanks,
James
Unfortunately Apps Script doesn't allow you to request additional scopes for your advanced services. The email and photos scopes aren't required to execute the method, but are required to return email and photo data in the response. You can follow issue 3070 for progress on this problem.
Update 2015-08-17:
We just implemented a workaround, which is that the Classroom advanced service now always prompts for the following fixed set of scopes:
https://www.googleapis.com/auth/classroom.courses
https://www.googleapis.com/auth/classroom.rosters
https://www.googleapis.com/auth/classroom.profile.emails
https://www.googleapis.com/auth/classroom.profile.photos
This provides access to emails, but does mean that the scopes requested for a given script may be more than it actually needs. We hope this unblocks admins that are trying to use Apps Script to manage their Classroom data, while we work on a longer-term solution for dealing with optional scopes in Apps Script.

Resources