I have videos on vimeo and turned on the private mode so nobody can see my videos on vimeo. Now I have placed some of those videos inside albums and want to access them. but I just don't know how to do that? this is what I have done so far:
let webApiUrl = 'https://api.vimeo.com/users/<user_id>/albums/<album_id>/videos;
const { data } = await axios.get(webApiUrl,
{
headers: {"Authorization" : `Bearer ${access_token}`}
});
I have found the solution. Actually I followed the official docs which only mention about public scope which helps in accessing public data. So in order to get private data I generated new access token with private scope and put it in above mentioned code and got the private data easily.
Related
I am replacing a Project built using ASP.NET WebForms and I need to replace the .ashx Generic Handlers - but I need to keep the page names so an app that has these URIs hardcoded does not require updating.
I know how to deal with the logic, that is not the problem. The problem is that these pages are referenced by an app that I do not want to update, so I need to be able to use URIs that point to pages ending in .ashx.
I have tried everything I can think of. I had hoped to just use the #page directive as shown below:
#page "/mygenerichandler.ashx"
Unfortunately, that does not work. If it did, I would be all set.
I have seen pages telling me to handle the .ashx as a sort of parameter:
#page "/mygenerichandler/{ashx}" (and variations of this, none work)
This does not work.
I have tried just naming the pages with the .ashx extension. This does not work.
I do not want to have to update the apps that have the URLs embedded in them, but it is looking more and more like that is my only option.
Is there any way to accept a page request in Blazor to a page that is named something like "mygenerichandler.ashx"?
I figured it out. I am using the Middleware Pattern, and it turns out that this will execute early in the pipeline and allow me to inspect the URL for the .ashx extension and then route accordingly. I should be able to return a response from this point - I still have to implement that code, but it is not directly germane to this question so I will not cover it here.
public class HandlerTrapper
{
private readonly RequestDelegate _next;
public string? AccountID { get; set; }
public HandlerTrapper(RequestDelegate next)
{
_next = next;
}
public Task Invoke(HttpContext httpContext) //, [FromQuery(Name = "AccountID")] string accountId
{
string? page = httpContext.Request.Path.Value?.Replace(#"/", "");
Console.WriteLine("Page Name is {0}, AccountID = {1}", page, AccountID);
if(page==null || !page.Contains(".ashx"))
return _next(httpContext);
AccountID = httpContext.Request.Query["AccountID"];
switch (page)
{
case "GetAmzRefreshToken":
break;
}
return _next(httpContext);
}
private
}
// Extension method used to add the middleware to the HTTP request pipeline.
public static class HandlerTrapperExtensions
{
public static IApplicationBuilder UseHandlerTrapper(this IApplicationBuilder builder)
{
return builder.UseMiddleware<HandlerTrapper>();
}
}
This is called as shown here in Program.cs:
app.UseHandlerTrapper();
I am pretty sure I can just return a Response from here and after implementing the code that does the work based on the incoming legacy page name, I should have a replacement for my .ashx Generic Handlers.
There is an even better solution which I implemented in my code. The WebApplication class has a UrlReWriter method that solves this problem quite elegantly when used in conjunction with the Controller Routing.
I added these lines to my Program.cs file - I placed them before the UseHttpRedirection and the UseRouting calls.:
RewriteOptions urlOptions = new RewriteOptions().AddRewrite(#"^(.*).ashx$", "api/$1", false);
urlOptions.AddRewrite(#"^(.*).inf$", "api/ComputerInfo", false);
app.UseRewriter(urlOptions);
That resolved the issue for both of the file type patterns I needed to handle, and I can add more if need be.
I am using the following code to generate a JSON for a Salesforce custom object called Resource Booking. How can I "run" the file (or call responseJSON) so that when I input the custom URL (in the first comment) it jumps to a page similar to this example web page? https://www.googleapis.com/customsearch/v1?json
Here is my code:
#RestResource(urlMapping='/demo/createTask/*') //endpoint definition > {Salesforce Base URL}/services/apexrest/demo/createTask/
global class ResourceBookingTransfer {
public List<Resource_Booking__c> resourceBookingList{get; set;}
public ResourceBookingTransfer(ApexPages.StandardController controller) {
//getResourceBookingList();
}
#HttpGet //HttpGet request
global static responseWrapper getResourceBookingList() {
responseWrapper responseJSON = new responseWrapper(); //responseWrapper object for API response
responseJSON.message = 'Hello World';
return responseJSON; //return the JSON response
//resourceBookingList = Database.query('SELECT Booking_ID__c, Booking_Name__c, Start_Date_Time__c, End_Date_Time__c, Resource__c FROM Resource_Booking__c');
}
//wrapper class for the response to an API request
global class responseWrapper {
global String message {get;set;} //message string
//constructor
global responseWrapper() {
this.message = '';
}
}
}
To just test it - it might be simplest to use https://workbench.developerforce.com. There's "REST explorer" menu in there. Your code should be available under resource similar to /services/apexrest/demo/createTask.
Why that url? Read https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_code_sample_basic.htm
Once you're happy with this manual testing - you can try to do it from outside workbench. Workbench logs you in to SF and passed header with valid session id in the background. If you want to call your service from another website or mobile app - you need to perform login call first, get the session id and then run your code. There are several OAuth flows you can use to do this depending in what your app needs, maybe start with this one: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm
i followed the youtube data api to rate the video from the app. But i got "not found 404 error."
https://www.googleapis.com/youtube/v3/videos/rate?id=Z98hXV9GmzY&rating=like&access_token="+token+"&key=XXXXX
what is the right way to do that... Any help is appreciated. Thankyou
I'm using codename one platform for the app by the way..
Login gc = GoogleConnect.getInstance();
gc.setCallback(new LoginCallback() {
#Override
public void loginFailed(String errorMessage) {
Dialog.show("Error Logging In", "There was an error logging in: " + errorMessage, "OK", null);
}
#Override
public void loginSuccessful() {
Dialog.show("Logged In", "you are currently logged in ", "OK", null);
}
});
if (!gc.isUserLoggedIn()) {
gc.doLogin();
} else {
token = gc.getAccessToken().getToken();
}
});
findLikes(f).addActionListener((e) -> {
ConnectionRequest cr = new ConnectionRequest() {
#Override
protected void readResponse(InputStream input) throws IOException {
super.readResponse(input);
}
#Override
protected void postResponse() {
super.postResponse();
}
};
cr.setPost(false);
cr.setUrl("https://www.googleapis.com/youtube/v3/videos/rate?id=" + videoId + "&rating=like&access_token="+token+"&key=XXXXX"); //this doesnt give anything... is it not the right way??
cr.setDuplicateSupported(true);
NetworkManager.getInstance().addToQueueAndWait(cr);
});
you can not directly rate from the url. you need to use full rating code to give rate.
Youtube API
because firstly google authenticate of your application then it allows you to give rate Not directly from the
Your link
First off please tell use what language you are using I cant figure it out exactly from your code.
Videos: rate Add a like or dislike rating to a video or remove a rating from a video.
POST https://www.googleapis.com/youtube/v3/videos/rate
Remember this call is a http post not a HTTP GET. Ie you cant just place it in a web browser.
example:
POST https://www.googleapis.com/youtube/v3/videos/rate?id=b_bJQgZdjzo&rating=like&oauth_token={YOUR_accessTOken}
I am pretty sure it is oauth_token you use not key or access_token.
I am trying to implement AppWarp into a game I am making. I followed a tutorial exactly as it was written but I am getting about a dozen errors at "NetworkPeer implements". Some of the errors are:
Error: Interface method onConnectDone in namespace com.shephertz.appwarp.listener:ConnectionRequestListener not implemented by class NetworkPeer.
Error: Interface method onDisConnectDone in namespace com.shephertz.appwarp.listener:ConnectionRequestListener not implemented by class NetworkPeer.
And so on...
Any help is greatly appreciated!
public class NetworkPeer implements ConnectionRequestListener, RoomRequestListener, NotificationListener
{
public var roomID:String = "Room";
private var apiKey:String = "API_ID"
private var secretKey:String = "Secret_Key";
private var localUsername = Math.random().toString();
public function NetworkPeer()
{
WarpClient.initialize(apiKey, secretKey);
WarpClient.getInstance().setConnectionRequestListener(null);
WarpClient.getInstance().setRoomRequestListener(null);
WarpClient.getInstance().setNotificationListener(null);
}
private function connect_click(e:MouseEvent):void
{
if (WarpClient.getInstance().getConnectionState() == ConnectionState.disconnected)
{
WarpClient.getInstance().connect(localUsername);
Main.connectbtn.text = "Connecting..";
}
}
}
You are getting this error because, you have implemented listeners like ConnectionRequestListener to NetWorkPeer class but not defined corresponding callback methods like onConnectDone in NetworkPeer.
The AppWarp APIs are developed to be used asynchronously, and in order to receive responses and updates from the AppWarp Server, you need to add corresponding request listeners to the WarpClient instance.
In the code snippets, you are adding null as listener which is not needed. You only need to add the listeners and its callback methods which you want to receive in your game.
For example, if you call connect API then you need to add ConnectionRequestListener and define onConnectDone callback method to get the response from the AppWarp Server.
You can have a look at this sample to know more about the integration of AppWarp into your ActionScript project.
You can also go through the AppWarp Getting Started page for Action Script to know more about the necessary steps which need to be done.
If you face any further problems , you can always write on our Forum or on support#shephertz.com.
I am trying to integrate Box with Kerika using box-java-sdk-v2. Library is added as maven dependency (net.box:boxjavalibv2) in the project.
Everything is working fine, except the update collaboration API. API call from the project looks like follow:
BoxCollabRequestObject requestObject = BoxCollabRequestObject.updateCollaborationObject(permission);
return client().getCollaborationsManager().
updateCollaboration(collaborationId, requestObject);
I searched google a lot to find the solution of this. But, I didn't get any. So, I have logged the issue at box-java-sdk-v2 issues on GitLab.
After spending some more time after a day a found that issue is with the Java library itself. There isn't any problem with Box API. I concluded this by accessing REST API directly from Advanced REST Client instead of Java library, and it worked.
So, as work around (Until the bug from the Java SDK is not officially fixed and release), I have updated my code as follows:
// As client library update function is not working properly so I have written custom code to deal with it.
BoxCollabRequestObject requestObject = BoxCollabRequestObject.updateCollabObjects(permission);
BoxCollaborationsManagerImpl boxCollaborationsManager = (BoxCollaborationsManagerImpl)client().getCollaborationsManager();
BoxUpdateCollaborationRequest request = new BoxUpdateCollaborationRequest(boxCollaborationsManager.getConfig(), boxCollaborationsManager.getJSONParser(), collaborationId, requestObject);
return (BoxCollaboration) boxCollaborationsManager.getResponseAndParseAndTryCast(request, BoxResourceType.COLLABORATION, boxCollaborationsManager.getJSONParser());
and the BoxUpdateCollaborationRequest class in the above code is self made. It looks like as follow:
public class BoxUpdateCollaborationRequest extends DefaultBoxRequest
{
private static final String URI = "/collaborations/%s";
public BoxUpdateCollaborationRequest(IBoxConfig config, IBoxJSONParser parser, String id, BoxCollabRequestObject requestObject) throws BoxRestException
{
super(config, parser, getUri(id), RestMethod.PUT, requestObject);
}
public static String getUri(final String id) {
return String.format(URI, id);
}
}
I noticed that the real problem in their original implementation is just the constant. It should be
private static final String URI = "/collaborations/%s";
Instead of
private static final String URI = "/collaboration/%s";
I am filing this issue here to help others who is having the same issue and searching Stack Overflow for the solution.