Facebook Graph API version not supported - python-3.x

I want to access a facebook page data, and my fb Graph API version is 3.1, when i am writting this(in python):
graph = facebook.GraphAPI(access_token=token, version = 3.1)
it gives a version error, i.e:
facebook.GraphAPIError: Valid API versions are '2.7', '2.8', '2.9', '2.10', '2.11', '2.12', '3.0'
how can i access facebook Graph API through my version in python.
Thanks in advance.

You will either
have to use an app id that still allows you to use a lower API version, or
wait for an update of the library, or
see where the library does this check and manually add 3.1 to the list there.
If you are using this library https://github.com/mobolic/facebook-sdk/, you can edit the __init__.py file, which currently contains the following line:
VALID_API_VERSIONS = ["2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "3.0"]
If you add "3.1" to that list, you should be able to use API version 3.1 without getting this error.

Related

Graph SDK for .NET doesn't have Request method

I'm trying to use the Graph SDK and NuGet 5.0.0-preview16 and forwarding the example it says to use Request method in example
var users = await graphClient.Users.Request().GetAsync();
but I have an error in the code:
'UsersRequestBuilder' does not contain a definition for 'Request' and
no accessible extension method 'Request' accepting a first argument of
type 'UsersRequestBuilder' could be found (are you missing a using
directive or an assembly reference?
Since C# SDK V5 Request method is removed and you can call directly GetAsync method. But V5 is still in preview and it's better to use latest V4 version.
var users = await graphClient.Users.GetAsync();
Upgrade guide can be found here.
Fixed: I changed Microsoft.Graph on NuGet from 5.0.0-preview16 to 4.47.0

What is suggested method to get service versions

What is the best way to get list of service versions in google app engine in flex env? (from service instance in Python 3). I want to authenticate using service account json keys file. I need to find currently default version (with most of traffic).
Is there any lib I can use like googleapiclient.discovery, or google.appengine.api.modules? Or I should build it from scratches and request REST api on apps.services.versions.list using oauth? I couldn't not find any information in google docs..
https://cloud.google.com/appengine/docs/standard/python3/python-differences#cloud_client_libraries
Finally I was able to solve it. Simple things on GAE became big problems..
SOLUTION:
I have path to service_account.json set in GOOGLE_APPLICATION_CREDENTIALS env variable. Then you can use google.auth.default
from googleapiclient.discovery import build
import google.auth
creds, project = google.auth.default(scopes=['https://www.googleapis.com/auth/cloud-platform.read-only'])
service = build('appengine', 'v1', credentials=creds, cache_discovery=False)
data = service.apps().services().get(appsId=APPLICATION_ID, servicesId=SERVICE_ID).execute()
print data['split']['allocations']
Return value is allocations dictionary with versions as keys and traffic percents in values.
All the best!
You can use Google's Python Client Library to interact with the Google App Engine Admin API, in order to get the list of a GAE service versions.
Once you have google-api-python-client installed, you might want to use the list method to list all services in your application:
list(appsId, pageSize=None, pageToken=None, x__xgafv=None)
The arguments of the method should include the following:
appsId: string, Part of `name`. Name of the resource requested. Example: apps/myapp. (required)
pageSize: integer, Maximum results to return per page.
pageToken: string, Continuation token for fetching the next page of results.
x__xgafv: string, V1 error format. Allowed values: v1 error format, v2 error format
You can find more information on this method in the link mentioned above.

how to set default application version in azure batch using java sdk

Is there a way to set the default application version in azure batch account using java sdk?
The sample script that they have in the git does not show how to set the default version(https://github.com/Azure-Samples/batch-java-manage-batch-accounts/blob/master/src/main/java/com/microsoft/azure/management/batch/samples/ManageBatchAccount.java).
Also I was trying to dig in the interface(https://github.com/Azure/azure-libraries-for-java/blob/master/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/Application.java) to get some clues but couldn't see anything that supports updating the default version.
UPDATE:
I was able to get the version update working following #brklein suggestion:
BatchApplication batchApplication = batchAccount.applications().get(applicationName)
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(applicationId, tenantId, appSecret, AzureEnvironment.AZURE)
BatchManager batchManager = BatchManager.authenticate(credentials, subscriptionId)
ApplicationsInner applicationsInner = batchManager.inner().applications()
ApplicationUpdateParameters parameters = new ApplicationUpdateParameters(defaultVersion: DEFAULT_APP_VERSION)
applicationsInner.update(resourceGroupName, batchAccountName, batchApplication.id(), parameters)
It does not appear that default version is being surface at the client layer of the SDK.
To get around this you should be able to call the implementation methods manually, which have the full functionality of the REST API (as they are auto-generated).
To do this create either CreateApplicationParameters or ApplicationUpdateParameters and set the defaultVersion property. Then you can call the implementations create or update methods manually (https://github.com/Azure/azure-libraries-for-java/blob/78e8ff2940eba34bc63f8e7be6807a377500f5c7/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java#L474).

Swagger UI not working with Swashbuckle latest version

I am using Swashbuckle 5.3 version in my .NET Web API with Basic Authentication (as per this link). Now when I am trying to update with Swashbuckle 5.6 version, it's throwing error 'Key is not found'.
The issue is at following code snippet. During route mapping, it's not able to find 'swagger_ui' from route collections. I tried with other different route values ( like 'swagger' , '/swagger','swagger/docs' ) but none of them is working
var route = config.Routes["swagger_ui"];
config.Routes.Remove("swagger_ui");
config.Routes.MapHttpRoute("swagger_ui", route.RouteTemplate, route.Defaults, route.Constraints, new AuthMessageHandler(route.Handler));
I replaced 'swagger_ui' with 'swagger_ui_shortcut' and it works :) I did change by referring this [link] (https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Application/HttpConfigurationExtensions.cs)
But I will investigate for proper solution

Foxx oauth2 configuration

To play with the demo-sessions app, I've got the oauth2 app mounted on /oauth2 as required.
In arangodb/Foxx doc, the oauth2 endpoints seems to be defined as strings (i.e https://github.com/arangodb-foxx/util-oauth2 )
But when I perform that with correct urls, and try to play with oauth, I've got an error :
...\oauth2\APP\manifest.json\": attribute child \"authEndpoint\" fails because [\"authEndpoint\" must be an object] (was \"[object Object]\").]","...
Oauth endpoints definitions are expected to be objects, not strings.
So what is the correct configuration for Foxx oauth2 ?
Thanks for help,
I can't reproduce your problem but the OAuth2 app has been updated for ArangoDB 2.7. You can still install odler versions of the OAuth2 app from the "install from GitHub" dialog, though.
I understand my mistake. In the code of the oauth2 2.0 release, the manifest just references the export.js file. In the previous release (1.2), a providers.js file was supplied and referenced in the manifest. Then in this previous release, it was possible to use different providers (what I want) as described in the 1.2 setup.js.
var providers = db._collection(providersName);
I just fetch the files providers.js, and setup.js from 1.2 github tag and configure them for my configuration, and that's ok.

Resources