Get youtube video's comments - dart - google-api

I'am trying to get youtube video's comments from my dart console application. I create application in google console.
Then I try to get video list:
import "package:googleapis/youtube/v3.dart" as youtube;
import "package:http/http.dart" as http;
void main() {
http.Client client = new http.Client();
youtube.YoutubeApi api = new youtube.YoutubeApi(client);
api.videos.list("title", id: "ZkGSR0Q492g").then((youtube.VideoListResponse list) {
// print("List length: " + list.items.length);
});
}
When I run this file in console - I get error:
Uncaught Error: DetailedApiRequestError(status: 403, message: Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.)
I understand that I never indicated API-key applications. I think that the error due to this.
But I can not figure out where I need to specify it?

I guess you need to create an authenticated client using https://pub.dartlang.org/packages/google_oauth2_client (detailed instructions in the README.md)

Now I use package "googleapis_oauth". And in this package we have method clientViaApiKey in auth_io.dart. This is solve my problem.

Related

Why is dataObjectDeserializer.getObject() not present?

I have created a spring-boot server for handling stripe webhooks.
However, webhooks are working - I am getting an event, but when i try to get the value of dataObjectDeserializer.getObject() its null. Any ideas why that might be and how to fix it.
Here is the code:
Event event = null;
try {
event = Webhook.constructEvent(
payload, sigHeader, endpointSecret
);
} catch (SignatureVerificationException e) {
// Invalid signature
logger.info("Webhook error while validating signature.");
return "";
}
EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
StripeObject stripeObject = null;
if (dataObjectDeserializer.getObject().isPresent()) {
stripeObject = dataObjectDeserializer.getObject().get();
} else {
// Deserialization failed, probably due to an API version mismatch.
// Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
// instructions on how to handle this case, or return an error here.
}
I ran into the same issue recently.
In my case (Which I believe might be yours as well). Is that the Event is not being properly deserialized because a version mismatch between the API you are using in your account and the models of the Stripe SDK in your project. You can check this by looking into: Event.getApiVersion() and Stripe.API_VERSION.
If they differ then you will need to properly upgrade them and take in consideration migration guidelines if they apply to your scenario.
On my case since it was a first time I didn't need to go through any migration and I just simply when to my dash board and upgrade the sdk:
Dashboard Note: It displays rollback because I did upgrade it. If you haven't you will have a "Upgrade" option available.
You can find more info on their documentation page:
Upgrade Stripe API
Versioning
Hope this helps!

Optimizely object is not valid. Failing isFeatureEnabled

I'm trying to use the React and JavaScript SDKs for Optimizely, but getting the following error in the console:
OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
More info about my setup below:
Installed via Yarn: yarn add #optimizely/react-sdk
Import statement in the app container:
import {
createInstance
} from '#optimizely/react-sdk'
Logic in render function:
const optimizely = createInstance({
sdkKey: '<SDK_KEY>',
})
const enabled = optimizely.isFeatureEnabled('example_feature', 'user123');
I get this error in the Chrome console:
OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
The Optimizely object will log that error when you call isFeatureEnabled before the SDK has successfully loaded your project's datafile. This can happen for a number of reasons outlined below. Looking at the code example provided in the question, it looks like reason #4 is the most likely cause of the error, but here are all of them:
1. Bad SDK key
If you pass in a bad SDK Key to createInstance, the SDK will not successfully load the datafile and you will get this error.
const optimizely = createInstance({
sdkKey: 'invalid-sdk-key'
})
2. Malformed datafile
If you are passing in the datafile directly to createInstance, but pass in an object that isn't the proper datafile format, you will get this error:
const optimizely = createInstance({
datafile: { wrong: 'format' }
})
3. Inaccessible datafile
Make sure you can access the url of your datafile in a web browser: https://cdn.optimizely.com/datafiles/<Your_SDK_Key>.json. If you get an AccessDenied (403) or Not Found (404) error and your account is new, make sure you create something in the Optimizely UI so that Optimizely is triggered to create and upload a proper datafile.
If in the console of your running application you see a 403 or 404 for the request to the datafile, ensure there are no ad-blockers, firewalls, or proxies preventing the SDK from requesting the datafile on Optimizely's CDN from the SDK.
4. Not waiting for Optimizely SDK to be ready
Even if you have the right SDK Key and the SDK can access Optimizely's CDN. If you don't give the SDK enough time for the datafile request to finish, you will be trying to use the SDK before it's ready.
In the JavaScript SDK, this can be solved by using the onReady method:
const optimizely = createInstance({
sdkKey: 'valid-sdk-key',
});
optimizely.onReady().then(() => {
// optimizely is ready to use, with datafile downloaded from the Optimizely CDN
});
If using the <OptimizelyFeature> component of the React SDK, then the <OptimizelyFeature> component will automatically wait until the <OptimizelyProvider> has successfully loaded the datafile before evaluating isFeatureEnabled.
My Firefox console error was
[OPTIMIZELY] - ERROR <timestamp> OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
One of my network failures gave me a big clue. The GET request for cdn.optimizely.com showed "Blocked by AdBlocker Ultimate" under the Transferred column.
Solution
I turned off my ad blocker for this site.

How to send print log from flutter app?

How to get print console log and screen capture so that I can send stack trace to server?
You can get a screenshot of the FlutterView using native code.
On Android: Bitmap screenshot = flutterView.getBitmap();
On iOS, see this example from Apple.
See the platform channels documentation on mixing Dart and native code.
As for the stack trace, here are some tips from the Flutter Sentry library documentation.
To get a stack trace from within Flutter, override the onError handler:
FlutterError.onError = (FlutterErrorDetails details) async {
throw details;
};
To create a Zone with an error handler that catches all Dart exceptions, wrap your call to runApp in runZoned:
runZoned<Future<Null>>(() async {
runApp(new MyApp());
}, onError: (error, stackTrace) async {
if (error is FlutterErrorDetails) {
// use error.exception and error.stack
} else {
// use error and stackTrace
}
});
you can use f_logs package, this has a functionality on export logs to a directory on the phone, it has .db and .txt for the logs, and then you can use flutter_archive package to zip the file, and then use flutter_email_sender to send the zip file that contains the logs your development team. It worked for us, hope this will helps.

Gmail Gadget Error 406 being thrown on osapi.http.post

We have multiple marketplace Apps that use Gmail Contextual Gadgets. These have been running for years successfully.
We are now noticing the following intermittent error being thrown when calling out to an external web server using open social osapi.http.post
"{"id":"http.post","error":{"message":"Response not valid JSON","code":406}}"
We have checked and there is nothing wrong with our server. We can make the call directly to our server successfully without fail.
We can replicate the issue calling to multiple servers running different apps/gadgets. The only commonality appears to be the use of osapi.http.post.
Here is the post
osapi.http.post({
'body': postdata,
'href': serverUrl + 'iLinkStreamer.ashx?data=' + "" + setTimeStamp() + debugString,
'format': 'json',
'authz': 'signed',
'noCache': true
}).execute(displayStreamList);
which raises the 406 error as above
Has anybody else noticed this issue?? Not sure how we can address it?
I had the same issue for a while and finally found the problem. I was also invoking external resources using osapi.http.post. I read the new documentation and found that there is a new way to do the same.
Check this url for more details, but the idea is that now you'll need to use makeRequest API, it will look something like this:
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
gadgets.io.makeRequest("https://your.backend.com", on_response_function, params);
...
def on_response_function(response){ ... }
I hope this helps someone.
I'm not sure if I'm the only one, but I never received a notification message that the previous API will be deprecated. :(

Pinterest Authentication with iOS-PDK

I have been struggling with the simple task of authenticating with the ios-pdk. This has worked for me in the past but it is not consistent. I have followed all the instructions I can find: set up a re-direct uri and I am using the the latest XCode 7 with Swift 2. I am concerned it may be related to my latest upgrade. My call looks like this:
let permission = [PDKClientReadPublicPermissions]
PDKClient.sharedInstance().authenticateWithPermissions(permission,
withSuccess: { (responseObject :PDKResponseObject!) -> Void in
print("success PDKResponseObject: \(responseObject)")
}) { (err :NSError!) -> Void in
print("error NSError: \(err)")
}
Over the past few days, sometimes I receive a success and other days I receive an internal server error! Has anyone seen this behavior?
Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo={com.alamofire.serialization.response.error.response= { URL: https://api.pinterest.com/v1/me/?access_token=[access_token_here]&fields=counts%28pins%2Clikes%2Cboards%29%2Cid%2Cbio%2Clast_name%2Ccreated_at%2Cusername%2Cimage%2Cfirst_name } { status code: 500
Thanks, Anita
i think this may have been fixed with this pull request: https://github.com/pinterest/ios-pdk/commit/4386ef09ee988de1f73511552fb3e35d721962b6
I realized that unauthorized error I was receiving was due to the fact that the account I was testing with was not listed as a collaborator for my app.

Resources