Box API get shared file results in 404 - box-api

Already looked at How to use box-api to get the Shared item? and Box Developers documentation https://developers.box.com/docs/#shared-items. I have tried doing a request to https://api.box.com/2.0/shared_items in .NET code, in Firefox Poster and using curl. They all resulted in 404. I have verified that my file's shared link is open to anyone with a link. Here's my curl code (sanitized):
curl https://api.box.com/2.0/shared_items -H "Authorization: Bo
xAuth api_key=xxxxxxxxxxxxxxxxxxxxx" -H "BoxApi: shared_link=https://
app.box.com/s/yyyyyyyyyyyyyyyyyyyyyyyyyyyy"
{"type":"error","status":404,"code":"not_found","help_url":"http:\/\/developers.
box.com\/docs\/#errors","message":"Not Found","request_id":"196207167555469c3017
14b"}
What might be the problem? I tried a wrong api_key and got back 401 so I know the whole setup is correct.

Your API key shouldn't be included anywhere in the request. I believe that form of authorization was used in the old v1 API and is now deprecated. There's a cURL example in the docs you linked to that shows what your authorization header should look like:
curl https://api.box.com/2.0/shared_items
-H "Authorization: Bearer ACCESS_CODE"
-H "BoxApi: shared_link=SHARED_LINK"
For more info on how to obtain the access token that goes into the authorization header, take a look at the OAuth tutorial.
The reason why authentication is required is because the API will return info about the item within the context of the caller's permissions. For example, if the creator of the shared link makes the API call, then private information (such as the item's full path within their account) will be returned. If another user makes the call, then that private information will be omitted.
That being said, you're still able to anonymously download an open shared link by navigating to it directly. You only need to use the API if you want more information about the item that the link points to.

Related

Consumer API - Cards

I have completed the Build Your First Plugin tutorial and that’s all working fine. I have retrieved my account using the Consumer API with the Node.js Express app and from the command line with curl.
The Accounts API seems rather straightforward. Now I’m trying to determine how I go about retrieving the debit cards associated with my account?
I’m looking at the OpenAPI / Swagger stuff, but I’m not sure how to get Cards API to work exactly.
Accounts - From the Accounts API doc, I copied this userId, 01234567-abcd-4321-fedc-9876543210fa, to use in the Cards API.
Cards
The Cards API is used to perform actions related to credit/debit
cards.
As you can see in this screenshot, I pasted the userId that I copied from the Accounts API doc.
Cards API screenshot - The response was a 401:
“Failed to determine Banno auth type”
I suspect this has something to do with selecting the proper OpenID scopes?
I clicked the lock icon next to the Basic Cards API Get button. I selected the two OpenID scopes that it showed as being required?
CardControls-ReadOnly
CardControls-ReadWrite
When I click the Authorize button it redirects to the digital.garden-fi.com site, but I don’t recall seeing a user name and password that I can use to test.
I obviously didn’t want to put my personal information into this site just to create an account to test with.
Garden test site
There are a few different things to unpack in your question, so I'll do my best to separate things out.
1) To use the Consumer API's Cards endpoints, you'll definitely need to use the correct OAuth scopes when beginning the authentication flow.
For example, for the GET ​/users​/{userId}​/cards endpoint, you'll need to use either the https://api.banno.com/consumer/auth/cardcontrols.readonly or https://api.banno.com/consumer/auth/cardcontrols.readwrite scope. You only need one of them, not both.
This is what you would need to use as a curl command in the Terminal, for example:
curl -X 'GET' \
'https://[CONSUMER_API_ENVIRONMENT]/a/consumer/api/v0/users/{userId}/cards' \
-H 'accept: application/json' \
-H 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'
...where:
CONSUMER_API_ENVIRONMENT is specific to your financial institution and matches with Banno Online for your institution
userId is the ID for the User.
YOUR_ACCESS_TOKEN is your Access Token from the authentication flow (in JWT format)
Notably, you will need to user the userId for your user. Your question mentioned using 01234567-abcd-4321-fedc-9876543210fa, but from what I see that's not the ID of an actual user but is instead an example of how such an ID would be formatted. Apologies for the confusion.
2) The 'Interactive' API Reference
The 'interactive' API Reference that you're using is meant to be used with a demo financial institution that we have named Garden (https://www.garden-fi.com).
From what I can tell in your description, it sounds like you don't have a user nor API credentials for the Garden demo institution. Which is okay, because it's actually preferable for you to use a user and API credentials within your own financial institution.
Based on the fact that you've already gone through the Build Your First Plugin quickstart, it sounds like you've already got your own user and API credentials set up in your financial institution's Banno environment (which is actually ideal for what you're trying to do).
Again, apologies for the confusion.

How to obtain data from Canvas API?

I want to obtain data through canvas API from a moodle course that our institute is doing right now. I went through the documentation and I have generated an access token as advised in the API documentation. But now I don't know how to proceed.
I tried different examples in the chrome browser console.
ex: GET https:///login/oauth2/auth? client_id=XXX&response_type=code&redirect_uri=https://example.com/oauth_complete&state=YYY
But it didn't provide me any result. Instead I got errors such as "Uncaught SyntaxError: Unexpected identifier".
Can someone please tell me where should I start?
Thanks a lot.
You can generate an Access Token by going to "Account -> Settings -> New Access Token" Then copy down the access token.
Then you can make api calls by either
Attaching that access token to your request as a header curl -H "Authorization: Bearer <token>" 'http://<canvas>/api/v1/accounts/<account_id>/courses
or
Attaching the access token as a GET query parameter
http://<canvas>/api/v1/accounts/<account_id>/courses?access_token=token_of_magical_powers
Beware that the access token has all of the same privileges as the user for whom it was generated, so keep it guarded.
More documentation and examples can be found in the canvas community pages.

Google Drive API downloadUrl does not work

I have some audio recordings on Google Drive
the files are "viewable by anyone with the link"
I have created a podcast feed that links to these files
In order for a podcast client to download the files, it needs a direct download link. The Google Drive API returns two fields in a file's metadata that can play this role:
webContentLink is intended to be used in a browser. It allows my podcast client to download files less than 25MB; unfortunately, over this amount Google requires user confirmation since the file is not virus-scanned. This user-confirmation step prevents my podcast clients from downloading the file if it is over 25MB.
downloadUrl is what you're supposed to use, but I cannot get it to work at all. If I copy-paste a downloadUrl directly into my browser's address bar, I get nothing. Similarly my podcast client can't download anything with a downloadUrl.
This issue seems unresolved and suggests this is still broken, but I have a few questions:
should I need to submit an API key with the downloadUrl request? No key is needed for webContentLink.
is there a workaround for this issue?
When requesting the file with the downloadUrl you must specify the following authorization in your request header:
"Authorization: Bearer $token"
Where $token is the access_token returned by gapi for the user like this:
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token;
So if you were using curl the request would be something like this:
curl -o download -H "Authorization: Bearer $token" $downloadUrl

how to call rest api for sandbox paypal for payment verification

Hi am running paypal sample application it runs perfetct (Version 2.0 paypal sdk)
i used my sandbox client id in application
after successfulle payment it gives me json output
but i want to confirm that payment am confused how i can confirm it
i got some docs where they mention to use REST api of sandbox paypal and chek with it
but i dont know how to do it
below is the link
my problem is i dont know how to call below api on browser i have access token and payment id
https://api.sandbox.paypal.com/v1/payments/payment/PAYMENT ID\
-H "Content-Type: application/json" \
-H "Authorization: Bearer {accessToken}"
when am trying to run it as it is on browser with my input parameter it shows me
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://api.sandbox.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR"}
this message please help me out please
Dave from PayPal here.
Sometimes we see that INTERNAL_SERVICE_ERROR when you have made a payment using the same PayPal account for both payer and payee.
And sometimes INTERNAL_SERVICE_ERROR means that the Sandbox server is having a transient problem, in which case trying again after some time has passed will solve the problem.
Might either of these scenarios apply in your case?

Future of Google Location History API

Google will be retiring Latitude soon, along with Latitude's API. But they say on their blog that Location History will still be stored and users will be able to access their history on Google Maps' Location History Dashboard. Do you know if there will be any API for receiving that location history, as there was for Google Latitude?
I've discovered that I can dynamically load my location history for any date using the following url:
https://maps.google.com/locationhistory/b/0/kml?startTime=1373666400000&endTime=1373752800000
by changing timestamps in "startTime" and "endTime" parameters. Unfortunately it's in .kml and no granularity data is included. Come on, Google - Latitude has some devoted users who relay on it on daily basis, don't kill it :(
In case you want the data as JSON with accuracy and not just the locations, you can just make the same request that the website makes. Looking at the inspector shows that it makes a request to https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0. You can replay the same request with cURL (or any other way to make a POST request).
curl 'https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0' -H 'origin: https://maps.google.com' -H 'accept-encoding: gzip,deflate,sdch' -H 'x-manualheader: [SOME STRING]' -H 'accept-language: en-GB,en;q=0.8,en-US;q=0.6,de;q=0.4,pt;q=0.2' -H 'cookie: GDSESS=[COOKIE DATA]' -H 'x-client-data: [ANOTHER STRING]' -H 'user-agent: [UA STRING]' -H 'content-type: application/x-www-form-urlencoded;charset=UTF-8' -H 'accept: */*' -H 'cache-control: max-age=0' -H 'referer: https://maps.google.com/locationhistory/b/0' -H 'dnt: 1' --data '[null,[BEGIN],[END],true]' --compressed
I left out my private cookie data and some details (in [..]) but you can google chrome ask to generate this for you in the developer console (right click on request -> copy as cURL). Just adapt the begin adn end times and download your location history as JSON. However, you need to download ranges of a couple of days and not everything at once. I'll leave this as an exercise for the reader.
I too am searching for an alternative solution to get my location back from Google.
Here are some facts:
Latitude will be replaced with location sharing on Google+
Android devices will continue to report location data to Google
Latitude will be removed (API, friends, website ...)
If devices will still be sending location data, Google should give us an API to fetch that data.
I've been looking into it and my location is shown on my G+ profile, but no info about granularity or timestamp.
It just says "Current location: [geocoded city]".
Reverse geocoding that address isn't very accurate. If I click on the address, Google Maps is opened in a new tab with coordinates, which seem to be pretty accurate.
So, if my location is on G+, I should be able to get it via the G+ API, right?
Well..
The only thing I've been able to find was this:
https://developers.google.com/+/api/latest/people
"currentLocation": string,
As you can see, the location data is returned as a string. I haven't tried it yet, but I would bet money that it would return the same as on my profile, just the name of the city, but not more accurate than that.
Right now it sucks. I want to get my location info, if the device is already sending it.
Installing a 3rd party app on my phone to feed my location on another service is redundant. And let's not forget about the additional battery drain and mobile data usage.
The logical step would be to put all of the latitude functionality to Google+.
We'll see, I doubt it.
Right now it just seems that they will be feeding on our privacy without us having any control or insight into it. :(
You can also download the data from Google Takeout. I know that this isn't an API, per se, but even a manual import is probably better than nothing.
https://google.com/takeout/