Refresh access token failed with status code: 401 - c#

I'm trying to test botframework server on my localhost.
I followed the steps in https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0#step-3-enable-security-and-test-on-localhost- .
First I changed app config with the MicrosoftAppId and MicrosoftAppPassword passed the test of https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0#step-2 .
Then I started my bot on localhost and the web page shows it was running on http://localhost:3979/ .
But when I tried to test it on the Bot Framework Emulator, it returned 400 directline.postActivity with the message of "Refresh access token failed with status code: 401".
The screenshot is on https://i.loli.net/2019/06/06/5cf88ea120b9973175.png .
My botframework version is 3.13.1.
My Bot Framework Emulator version is 4.3.3.
What should I do to solve this problem?
Thanks for any help.
{
"error": {
"code": "ServiceError",
"message": "Refresh access token failed with status code: 401"
}
}
[11:42:22]POST 201 directline.start Conversation
[11:42:22]Emulator listening on http://localhost:49840
[11:42:22]ngrok listening on https://082d32c4.ngrok.io
[11:42:22]ngrok traffic inspector:http://127.0.0.1:4040
[11:42:22]Will bypass ngrok for local addresses
[11:42:25]->message hi
[11:42:26]POST 400 directline.postActivity

"Refresh access token failed with status code: 401" errors are almost always an issue with appId/appPass.
Please verify:
You have the correct appId/appPass from the App Registration Portal
Note: If you didn't save your password, just click "New client secret" to generate a new one.
Verify you set the correct appId/appPass in web.config
Verify that you entered the correct app/Id/appPass in Emulator:
You should also upgrade Emulator to the latest release. There was a bug in Emulator long before 4.3.3 that caused this error, but I guess there could be something similar with V3 bots, since we rarely use them.
If this is a new bot, you should really be using V4. V3 will be deprecated July 1, 2019. Existing bots will work, but users will no longer be able to create them.

Related

Sending mail via local IIS smtp server from ASP.NET core app silently fails

UPDATE: This turned out to be simple operator error - I failed to read the log file properly, which did indicate successful delivery on the IIS level.
Turns out that mails to this particular test address were blocked silently for unknown reasons unrelated to dotnet or IIS, by Gmail. Very sorry for posting something with such a simple solution and thanks to those that replied with helpful advice.
ORIGINAL QUESTION:
I have a Windows server with IIS SMTP server installed.
I'm trying to send mails from my ASP.NET Core app with this code:
var client = new SmtpClient();
client.Host = "127.0.0.1";
client.Send(mailMessage);
The code doesn't throw an exception, there is nothing in Windows error logs, nothing is logged to SMTP logs. It just fails silently.
The result of the Send() method is just the message itself, no error message or anything else helpful.
I tried in IIS to configure the SMTP Server but doesn't help.
I also tried other options like UseDefaultCredentials and to have it make a file in the Drop folder - in that case it says "not supported."
This exact same code works perfectly fine from my ASP.NET Standard app on the same server.
Thanks in advance! :-)
This turned out to be simple operator error - I failed to read the log file which indicated successful delivery on the IIS level. The mails to this particular test address were blocked silently for unknown reasons by Gmail. Very sorry for posting something with such a simple solution and thanks to those that replied with helpful advice.

C#/UWP : How to manage certificate errors with HttpClient?

I've developed an UWP app for a client, which uses WebServices that are hosted in its domain.
Until now, the URL WebServices were related to a test server that don't use SSL
But now, the WebServices URL are related to the prod server that use SSL
As I'm a subcontractor, I don't have an AD account, and I need to use the VPN to access to the client's WebServices.
I didn't get any problem to access to the test server, but it's no longer the case with the prod server.
When I try to access to access to the URL through a navigator, I get a security warning message (DLG_FLAGS_INVALID_CA), but I can "force" the navigation to the URL.
But when I call the WebService from the app with HttpCLient, I also get an error (HttpRequestException) and I don't see how I could fix it.
Here are the details of the exception:
HResult = -2147012851
InnerException =
{System.Runtime.InteropServices.COMException (0x80072F0D): Can't find text related to the error code. The certificate authority is invalid or is incorrect at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) ...
Message = "An error occurred while sending the request."
Source = "System.Net.Http"
I've already tried to install handly the certificates on my computer, but this doesn't fix the issue...
Is there another approach?
Edit: add "user" certificate
The client sent me the "user" certificate and I installed it on my computer in "User\Trusted Root Certification Authorities Certificate Store": there is no longer problem from the navigator. However, in the app, the problem is still present.
Is it normal? Do I need to "attach" the certificate to the app? This is not really usefull, as the client's users don't need this problem: it's only me as I'm a subcontractor using the VPN...
Edit: add "computer" certificate
Finally the client sent me the "computer" certificate and I installed it on my computer in "Computer\Trusted Root Certification Authorities Certificate Store": this time I could use the app without problem.
It's good to know that the UWP app and the navigators don't use the same certificate.
The problem has been fixed by installing the "user" and "computer" certificates that has been sent by the client.

Microsoft Bot Framework Bot duplicate responses in Slack

I have a simple code to test bot responses in my RoodDialog.cs code:
if (activity.Text.Trim().ToLower() == "--hi")
{
IMessageActivity replyMessage = context.MakeMessage();
replyMessage.Text = $"Hello {activity.From.Name}";
await context.PostAsync(replyMessage);
}
Works as expected in Skype, Emulator and Facebook Messenger, however sends duplicate response messages ("Hello {Name}") in Slack.
I think its either Slack configuration or a Bot Framework issue. Anyone seen and resolved this?
Thanks
Thanks to some Howdy developers I found the issue.
It happens when the bot has already been authorized to the team, and then someone else comes in and authorizes the bot again. When that happens, it seems there are two bots running that then use the same RTM connection to post to the channel twice.
I don't know how I got 2 bots in same Slack client. but once I removed and reinstalled my bot it started working as expected.
Same issue is causing this other symptom: Microsoft Bot Framework IDialogContext.Call() not working when using Slack

Paypal Sandbox (express-checkout) return internal error

since yesterday evening i've a problem with my "express-checkout API"
Every time if I called the uri
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-0W349......
I get the error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#paypal.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Yesterday in the morning everything was ok and since I didn't change anything also nothing on the API class.
My Server support the sha256 and the protocol Tls12.
I've nothing in the Logfile from server.
The Live environment works fine but the sandbox environment doesn't work since yesterday.
Is it an error on paypal site or on my side?
I've send also a mail to paypal but I get an autoresponse Message.
Please help me and sry for my bad english.
Thanks and best regards.
This may be related to the recent sandbox downtime over the past 24 hours or so. The problem was diagnosed by the team and they were able to repair the problem. Can you check again to see if it's working now please?

Feed subscription of a Page

I want to get notifications when a new feed has landed on a designated page (by page id). After what I understand, the Realtime-update og Graph API should be able to do this trick according to https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4.
So I want to add a new subscription, which I try to do with the following code:
dynamic result = client.Post(urlPath, new
{
#object = "page",
callback_url = callbackUrl,
fields = "feed",
verify_token = "654321",
access_token = accessToken
});
return result;
But when I try to run this, I'm getting the following error code:
(OAuthException - #2200) (#2200) callback verification failed: Received HTTP code 502 from proxy after CONNECT"
What do I miss?
The callback url is https://127.0.0.1:8989/ and I have a TcpListener running on the port, which does not seem to get any response/request incoming...
The application is a C# console application, so no fancy asp.net stuff or something. I'm using the Facebook .net SDK.
Should I FacebookClient.VerifyPostSubscription() or anything else that I missed out?? Maybe the SDK wraps a handle?
So the answer I'm looking for is:
- How do I create/add a subscription for feeds of a facebook page, using the .net SDK on a windows console project??
UPDATE:
I changed the loopback with a domain name, that I the NAT to my target machine, and now I actually get some encrypted data on my TcpListener!
So, the question now is, how do I respond correctly to this received respons, only by using a Tcp Client??
How you have to respond is exactly outlined in the docs you linked:
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4#setupget
It's not really clear what you mean with "TCP listener". You need to have some logic why can send HTTP responses to the Facebook servers, otherwise your service will be disregarded after some time, meaning no updates will be send.
Typically, this is implemented as a script/application in a web/application server.
Please note: The "C# SDK" is a third-party SDK and not officially supported by FB.

Categories

Resources