Twilio - Issue creating Client using token - twilio

I am new to Twilio and Angular!
I am creating a Twilio Client in Angular2 using Twilio Token which I am getting from the server. But I am getting below error.
I have already installed NuGet packages for Twilio-chat.
Code to create Twilio client.
const client = await Client.create(this.token);
Error
vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:2100 ERROR Error: Uncaught (in promise): Error: Can't connect to twilsock
Error: Can't connect to twilsock
at Upstream.send (upstream.js?6143:144)
at TwilsockClient.post (client.js?d83e:150)
at executeWithRetry (network.js?2fab:122)
at Retrier.retrier.on (network.js?2fab:78)
at Retrier.EventEmitter.emit (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:79200)
at Retrier.attempt (retrier.js?cc7c:28)
at timeout.setTimeout (retrier.js?cc7c:67)
at ZoneDelegate.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84187)
at Zone.runTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:83954)
at ZoneTask.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84262)
at ZoneTask.invoke (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84251)
at timer (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:85791)
at Upstream.send (upstream.js?6143:144)
at TwilsockClient.post (client.js?d83e:150)
at executeWithRetry (network.js?2fab:122)
at Retrier.retrier.on (network.js?2fab:78)
at Retrier.EventEmitter.emit (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:79200)
at Retrier.attempt (retrier.js?cc7c:28)
at timeout.setTimeout (retrier.js?cc7c:67)
at ZoneDelegate.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84187)
at Zone.runTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:83954)
at ZoneTask.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84262)
at ZoneTask.invoke (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84251)
at timer (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:85791)
at resolvePromise (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84575)
at resolvePromise (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84541)
at vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84624
at ZoneDelegate.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84187)
at Object.onInvokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:5392)
at ZoneDelegate.invokeTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84186)
at Zone.runTask (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:83954)
at drainMicroTaskQueue (vendor.js?v=Y21ivCkyOiPlokFTbKpKeeclguwnaH8po-6x_Nx58pI:84361)

Related

CompactToken parsing failed with error code: 80049217 while using Microsoft-graph-auth 0.2.0

We are using the following libraries:
microsoft-sdk-java-auth 0.2.0
microsoft-graph 2.3.1
microsoft-graph-core 1.0.5
java.util.List<String> scopes = new java.util.ArrayList<String>(); scopes.add("https://graph.microsoft.com/.default");
ClientCredentialProvider authProvider = new ClientCredentialProvider(clientId, scopes, clientSecret, tenantId, NationalCloud.Global);
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(authProvider).buildClient();
User user = graphClient.users(emailAddress).buildRequest().get();
We get this error sometimes while fetching any user's details.
ex- https://graph.microsoft.com/v1.0/users/email-addr#domain.com
Trace: com.microsoft.graph.http.GraphServiceException: Error code:
InvalidAuthenticationToken Error message: CompactToken parsing failed
with error code: 80049217
GET https://graph.microsoft.com/v1.0/users/email-addr#domain.com
SdkVersion : graph-java/v2.3.1 Authorization : [PII_REDACTED]
401 : Unauthorized
com.microsoft.graph.http.GraphServiceException.createFromConnection(GraphServiceException.java:501)
at
com.microsoft.graph.http.CoreHttpProvider.handleErrorResponse(CoreHttpProvider.java:503)
at
com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:423)
at
com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:220)
at
com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:200)
at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:345) at
com.microsoft.graph.requests.extensions.UserRequest.get(UserRequest.java:171)

How can I send Email from gmail to another email account

I think that this's an issue many coders are facing at the moment.
So let's find a solution:
I already tried ->
mailer2: ^1.2.5
var options = GmailSmtpOptions()
..username = ''
..password = '';
var emailTransport = SmtpTransport(options);
var envelope = Envelope()
..from = ''
..recipients.add(email)
..subject = ''
..html = "<h1>Title </h1>\n\n"
emailTransport.send(envelope)
.then((envelope) => print('Email sent!'))
.catchError((e) => print('Error occurred: $e'));
but the following error message came up:
Unsupported operation: Platform._localHostname
at Object.throw_ [as throw] (http://localhost:63913/dart_sdk.js:4463:11)
at Function._localHostname (http://localhost:63913/dart_sdk.js:54754:17)
at Function.get localHostname [as localHostname] (http://localhost:63913/dart_sdk.js:54810:33)
at get _localHostname (http://localhost:63913/dart_sdk.js:54713:27)
at Function.desc.get [as _localHostname] (http://localhost:63913/dart_sdk.js:4944:15)
at Function.get localHostname [as localHostname] (http://localhost:63913/dart_sdk.js:54666:26)
at mailer.GmailSmtpOptions.new.mailer.SmtpOptions.new
(http://localhost:63913/packages/mailer2/mailer.dart.lib.js:1178:30)
at new mailer.GmailSmtpOptions.new (http://localhost:63913/packages/mailer2/mailer.dart.lib.js:1229:43)
at http://localhost:63913/packages/bestbite_native/web/screens/screen_after_order.dart.lib.js:12394:37
at Generator.next (<anonymous>)
at runBody (http://localhost:63913/dart_sdk.js:37195:34)
at Object._async [as async] (http://localhost:63913/dart_sdk.js:37226:7)
at http://localhost:63913/packages/bestbite_native/web/screens/screen_after_order.dart.lib.js:12392:389
at _RootZone.runUnary (http://localhost:63913/dart_sdk.js:37029:58)
at _FutureListener.then.handleValue (http://localhost:63913/dart_sdk.js:32116:29)
at handleValueCallback (http://localhost:63913/dart_sdk.js:32663:49)
at Function._propagateToListeners (http://localhost:63913/dart_sdk.js:32701:17)
at _Future.new.[_completeWithValue] (http://localhost:63913/dart_sdk.js:32544:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:63913/dart_sdk.js:32566:35)
at Object._microtaskLoop (http://localhost:63913/dart_sdk.js:37290:13)
at _startMicrotaskLoop (http://localhost:63913/dart_sdk.js:37296:13)
at http://localhost:63913/dart_sdk.js:32918:9Error: Unsupported operation: Platform._localHostname
Does anybody has an idea how to send emails in flutter web applications?
(Without opening an email tab)
"mailer2"(and the original package "mailer") imports dart:io which is not available on flutter web and therefore you cannot use this package.
A solution I have used in the past for sending emails is to create an http-triggered cloud function(e.g. Firebase functions, AWS Lambda, netlify functions) that sends the email. You can pass any data you need through the http request and have the cloud function send the email through something like nodemailer in Node.js.
There also may be other services or APIs available that already do what the cloud function does, though I have not seen many and they are not my preferred method

Method for invoking transaction from another transaction in Hyperledge composer

The old version of hyperledger support below method. But newest not
const generateReport = getFactory().newTransaction('org.cusat.hospital', 'GenerateReport');
While testing in new version shows an error of
Error: No valid responses from any peers. Response from attempted peer comms was an error: Error: transaction returned with failure: TypeError: getFactory(...).newTransaction is not a function
Please suggest alternative method.
i found one way of invoking transaction from java script. see if this helps.
const TransactionSubmit = require('composer-cli').Transaction.Submit;
let options = {
card: 'admin#tutorial-network',
data: '{"$class":"net.biz.digitalPropertyNetwork.RegisterPropertyForSale","transactionId":"TRANSACTION_001","seller":"mae#biznet.org","title":"TITLE_001"}'
};
TransactionSubmit.handler(options);

Hyperledger composer calling external REST API

I am a developer with hyperledger composer. I try to use Calling an HTTP or REST API from Transaction Processor Functions with method POST and request body but I have error status code 500. I want to use method POST with request body to my server.
My code:
async function testStocks(transaction) {
const participant = getCurrentParticipant();
const json = '{"name:tester"}';//my request body
await request.post({ uri: 'http://www...', json });
// Update the current participant in the participant registry.
const participantRegistry = await getParticipantRegistry('org.example.Trader');
await participantRegistry.update(participant);
}
My error:
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: StatusCodeError: 400 - undefined",
"stack": "Error: Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: StatusCodeError: 400 - undefined\n at _initializeChannel.then.then.then.then.catch (/home/pc/.nvm/versions/node/v8.10.0/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:965:34)\n at <anonymous>"
}
}
participant variable is undefined in await participantRegistry.update(participant);.
You are missing code from the example # https://hyperledger.github.io/composer/latest/integrating/call-out.
// Get the current participant, and update their stock and balance.
const participant = getCurrentParticipant();
// update participant here... <<--------------------
// Update the current participant in the participant registry.
const participantRegistry = await getParticipantRegistry('org.example.Trader');
await participantRegistry.update(participant);

Authenticated YouTube Data v3 query fails with 403 Forbidden message

This is a c# .NET application. The app makes an OAuth2 authenticated YouTube Data v3 ChannelList query that had been working for two months. Recently, the query fails with a 403 Forbidden message from Google. It fails from our Azure Web server and when running in Visual Studio on a developer desktop. The query works for at least one user but fails for all others tested. The query (listed here) works for all users from within the API Explorer. I cannot find additional error description returned from Google.
Update (7/15/2013): The query now runs after adding the access_token to the query. Previously, it executed successfully with the access_token only in the Service object, not explicitly part of the query. Although the query is successful with access_token directly appended, we are getting a downstream JavaScript error on on the YouTube embedded player. Not sure if that is related. I see there was a .NET API update in late June. #Ikailan, did something change at Google to break the access_token auth in the Service object. Note: we DID update to the new API. Are changes required to our code to use the June 2013 API updates?
Error Message "The remote server returned an error: (403) Forbidden."
Method that was failing but now works with the Auth token added to the query.
//Gets the channel information of the current user
public static ChannelListResponse GetCurrentUserChannel(string token)
{
YouTubeService service = new YouTubeService(GlobalSettings.applicationName, GlobalSettings.developerKey);
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("YouTube", GlobalSettings.applicationName);
authFactory.Token = token;
service.RequestFactory = authFactory;
ChannelListResponse response = new ChannelListResponse();
try
{
System.IO.Stream resultStream = service.Query(new Uri("https://www.googleapis.com/youtube/v3/channels?part=id%2Csnippet%2CcontentDetails%2Cstatistics%2CtopicDetails&mine=true&access_token=" + authFactory.Token));
using (var reader = new System.IO.StreamReader(resultStream))
{
string value = reader.ReadToEnd();
response = JObject.Parse(value).ToObject<ChannelListResponse>();
}
}
catch (Exception ex) { }
return response;
}
Line that throws the exception. Added the Auth Key (see code above). Now the query executes successfully.
System.IO.Stream resultStream = service.Query(new Uri("https://www.googleapis.com/youtube/v3/channels?part=id%2Csnippet&mine=true"));
However, we are getting an Access Denied error for an embedded YouTube video player.
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
Exception was thrown at line 4224, column 4 in http://localhost:49185/YotaCast_Prototype/Scripts/jquery-1.9.1.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4242, column 4 in http://localhost:49185/YotaCast_Prototype/Scripts/jquery-1.9.1.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 360, column 9 in http://localhost:49185/YotaCast_Prototype/Scripts/foundation/foundation.js
0x800a1391 - JavaScript runtime error: 'Zepto' is undefined
Exception was thrown at line 1, column 97 in http://s.ytimg.com/yts/jsbin/www-embed-player-vflXN6WzI.js
0x80070005 - JavaScript runtime error: Access is denied.

Resources