I trying to use the Google OAuth 2.0 playground to query for realtime updates on a Google Docs File ID. For every request using either the get or update Realtime api calls I receive an error and have tried sending in numerous file ids. Do you have any advice as to how to use this API?
Below is the URL I am sending along with the error returned:
https://www.googleapis.com/drive/v2/files/1IT1qIuM6QsqV7D--69uv0sn4OSQ24UQKos3x0P3BQjc/realtime
Error Returned:
GET /drive/v2/files/1IT1qIuM6QsqV7D--69uv0sn4OSQ24UQKos3x0P3BQjc/realtime HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer ya29.LgDc0oNUU_4cuhoAAAAjT4pqiLwlIpoRV7ll_QEJp1QayB49KOwIYKHVK5rMww
HTTP/1.1 400 Bad Request
Content-length: 172
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Expires: Wed, 25 Jun 2014 10:08:21 GMT
Server: GSE
Cache-control: private, max-age=0
Date: Wed, 25 Jun 2014 10:08:21 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
{
"error": {
"code": 400,
"message": "Invalid Value",
"errors": [
{
"domain": "global",
"message": "Invalid Value",
"reason": "invalid"
}
]
}
}
Thanks,
Michael
You need to provide your API key at the end. You can see what the requests should look like in the API explorer.
Note however that realtime documents are scoped to a particular app, so anything you've created in your app won't show up in the API explorer. You can update and the get it from that using the explorer app though.
Related
New with REST and API Gateway.
I have installed Kong with Cassandra on a dev machine and I'm trying to add my API (spring-boot application) but reading the documentation I'm struggling to make it work.
My API:
http://ff-nginxdev-01:9003/fund-information-services/first-information/fund/{fundId}
when I run
http http://ff-nginxdev-01:9003/fund-information-services/first-information/fund/630
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Date: Fri, 25 Nov 2016 14:47:30 GMT
Transfer-Encoding: chunked
X-Application-Context: application:9003
{
"assetSplit": {
"allocationHistories": [
{
"key": {
"asset": {
"description": "Other Far East",
"id": 18
},
"assetSplit": "09",
"effectiveDate": 1430348400000
},
......
......
Everything look fine and I'm able to retrieve the Json message.
Adding the API in Kong:
http POST http://ff-nginxdev-01:8001/apis/ name=fund-information upstream_url=http://ff-nginxdev-01:9003/ request_path=/fund-information-services
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Fri, 25 Nov 2016 14:39:45 GMT
Server: kong/0.9.4
Transfer-Encoding: chunked
{
"created_at": 1480084785000,
"id": "fdcc76d7-e2a2-4816-8f27-d506fdd32c0a",
"name": "fund-information",
"preserve_host": false,
"request_path": "/fund-information-services",
"strip_request_path": false,
"upstream_url": "http://ff-nginxdev-01:9003/"
}
Testing Kong API Gateway:
http http://ff-nginxdev-01:8000/fund-information-services/first-information/fund/630
HTTP/1.1 502 Bad Gateway
Connection: keep-alive
Content-Type: text/plain; charset=UTF-8
Date: Fri, 25 Nov 2016 14:44:33 GMT
Server: kong/0.9.4
Transfer-Encoding: chunked
An invalid response was received from the upstream server
I know I'm missing something but it is not clear to me.
By default, Dynamic SSL plugin will binds a specific SSL certificate to the request_host in API.
You just define request_path in your API and that means SSL plugin does not apply when you use request_path.
You can read more to understand why it is like that in: this issue
To make your request works, I think you should read about how to proxy an API in: Proxy Reference
Here is my solution for your problem:
Method 1: Change "strip_request_path" to true
"strip_request_path": true
This method assume you didn't specify request_host first
Method 2: Using request_host instead
"request_host" : "your_api"
Then in your request header, you should add this request_host:
Example request:
curl -i -X POST --url http://ff-nginxdev-01:8000/fund-information-services/first-information/fund/630 --header 'Host: your_api'
and it will works
you missed the api name known by kong "fund-information", so if you do this
http POST http://ff-nginxdev-01:8001/apis/ name=fund-information upstream_url=http://ff-nginxdev-01:9003 request_path=/fund-information-services
your test url is
http http://ff-nginxdev-01:8000/fund-information/first-information/fund/630
I am trying to get the installed app to work with Oauth2 on Reddit's api. I am using Windows runtime api's httpclient to make requests, and webauthenticationbroker to get the code to do the GET request to receive the token. I requested a token by using this:
https://www.reddit.com/api/v1/authorize?client_id=" + client_id + "&response_type=code&state=" + "testing" + "&redirect_uri=http://abcd.com&duration=" + "permanent" + "&scope=" + "vote,identity"
And got a code back, so I used POST on this (with the content type being: application/x-www-form-urlencoded):
https://www.reddit.com/api/v1/access_token
with the body being this:
grant_type=https://oauth.reddit.com/grants/installed_client&\
device_id="+id + "&code=" + code
(code and id is the code received in the first step and id is a generated UUID)
Then I got something like this back:
{"access_token": "--5e65dP1dI_1vgLbqvi7zRB6cnU", "token_type": "bearer", "expires_in": 3600, "scope": "*"}
So I extracted the token and got this:
--5e65dP1dI_1vgLbqvi7zRB6cnU
Then I tried to do a GET request on https://oauth.reddit.com/api/v1/me with these headers:
{
User-Agent: (testUWP client by /u/bored_reddit_user)
Authorization: bearer --5e65dP1dI_1vgLbqvi7zRB6cnU
}
I got these headers back with status code 403 reason phrase forbidden:
{
Connection: keep-alive
Server: cloudflare-nginx
Strict-Transport-Security: max-age=15552000; includeSubDomains; preload
Transfer-Encoding: chunked
cache-control: max-age=0, must-revalidate
x-ua-compatible: IE=edge
CF-RAY: 23f5127a6a2911a1-SJC
Date: Tue, 03 Nov 2015 03:42:58 GMT
x-frame-options: SAMEORIGIN
access-control-allow-origin: *
X-Moose: majestic
x-reddit-tracking: https://pixel.redditmedia.com/pixel/of_destiny.png?v=BZoi0ikdGrSYn9U9xM6GWeYcRRb0W50fSQuGYb1Q8Oe7E5WVB6qTA4hRqlx9vDfpLOKzpE3Z5Wo%3D
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
access-control-expose-headers: X-Reddit-Tracking, X-Moose
}{
Content-Type: application/json; charset=UTF-8
}
and this content:
{"explanation": "Please log in to do that.", "reason": "USER_REQUIRED"}
I am at a loss as to what I'm doing wrong, can anyone help me out?
This wiki page on the reddit github gives a pretty good overview of reddit's implementation of OAuth2 and the different grant_types and what circumstances they are appropriate for. This page has some more information. I'm suspecting that reddit doesn't want you storing the client secret in an app that you install on a user's device since you can't keep it secure, and a user could figure out your CLIENT_ID.
I'm glad my comment could point you in the right direction, if you could accept this answer, I'd appreciate the rep.
My app keeps few app specific files in appdata folder. But when file tries to update the file in Drive app data repeatedly getting internal error from the Drive server. I am using Objective-c client to call Drive APIs.
Could you please help what is wrong in these. At least give few suggestion to find out the cause for this error.
Below is the logged request and response:
drive.files.update (bytes 0-40318/40319)
2014-05-19 09:23:44 +0000
Request: PUT https://www.googleapis.com/upload/rpc?uploadType=resumable&prettyPrint=false&upload_id=AEnB2Uo8yrae46aQQ-HYEtQgmXt2qNppZmkBYnPa8iXF4L6xdNYaVij6u3xLTT5kRIeH1mbPUUfUuEDEvYoouZheVwwWT6iw_A
Request headers:
Content-Length: 40319
Content-Range: bytes 0-40318/40319
Content-Type: binary/octet-stream
User-Agent: com.mycompanyname.appname/1.4.0 google-api-objc-client/2.0 MacOSX/10.8.5 (gzip)
Request body: (40319 bytes)
<<40319 bytes>>
Response: status 200
Response headers:
Alternate-Protocol: 443:quic
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 144
Content-Type: application/json; charset=UTF-8
Date: Mon, 19 May 2014 09:23:44 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: HTTP Upload Server Built on May 15 2014 11:06:48 (1400177208)
Response body: (144 bytes)
{
"error" : {
"message" : "Internal Error",
"data" : [
{
"reason" : "internalError",
"message" : "Internal Error",
"domain" : "global"
}
],
"code" : 500
},
"id" : "gtl_20"
}
-----------------------------------------------------------
Update
An excellent workaround proposed by Jon Skeet from:answer to this question
I've managed to reproduce the issue. Without setNewRevision(false) it
works - I realize that may not be feasible in all cases, but is it a
reasonable workaround for you for the moment?
However, I will on hold on such workaround at this moment. We prefer to have setNewRevision(false), to prevent from causing increased use of the user's data storage quota - http://developers.google.com/drive/v2/reference/files/update
This error is due to an undocumented limit of 200 pinned revisions for a file. As you mentioned, the workaround is either to not create a new revision on upload, or alternatively unpin some of your existing revisions.
Been seeing an empty return from the following API endpoint for about 12 hours (at least) now. Does anyone else have this problem?
https://api.instagram.com/v1/media/popular?client_id=
{"meta":{"code":200},"data":[]}
UPDATE 1:
This does appear to be a problem. You should contact support#instagram.com
I am facing it too. Here's what I get for a /media/popular endpoint GET after authenticating using my instagram login. The JSON returned shows HTTP Status code 200, but the data array is empty / null.
HTTP/1.1 200 OK
Content-Language:
en
X-Ratelimit-Limit:
5000
Vary:
Cookie, Accept-Language
Date:
Thu, 30 Jan 2014 17:26:03 GMT
Content-Length:
31
X-Ratelimit-Remaining:
4999
Set-Cookie:
csrftoken=c359b115ff344c48dfd1df1108aaf38b; expires=Thu, 29-Jan-2015 17:26:03 GMT; Max-Age=31449600; Path=/
Set-Cookie:
ccode=US; Path=/
Content-Type:
application/json; charset=utf-8
Server:
nginx
{
"meta": {
"code": 200
},
"data": []
}
PREVIOUS ANSWER (Deprecated)
The media/popular is an authenticated request, so shouldn't you be passing in the access_token and not the client_id for this request?
via the API Documentation:
https://api.instagram.com/v1/media/popular?access_token=ACCESS-TOKEN
Also, here's how you get the access_token using the client_id.
Their API pages and developer portal seem to be down with GATEWAY Errors. I'm guessing they are dealing with something at the moment.
i'm using the Explorer to just test out the API and get a feel for the data returned. On the top right corner of each API there is an "authorize using" switch. This asks me to auth with my google account. This all happens correctly and without error. When i try to use the "data.ga.get" method i get this error:
Request
GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key={YOUR_API_KEY}
Request
GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key={YOUR_API_KEY}
Authorization: OAuth ya29.AHES6ZSCqka0X1AVtMrW7iXn7VreLk71vfWB9MrnXCejBYY
X-JavaScript-User-Agent: Google APIs Explorer
Response
403 Forbidden
cache-control: private, max-age=0
content-type: application/json; charset=UTF-8
date: Tue, 28 Feb 2012 01:23:18 GMT
expires: Tue, 28 Feb 2012 01:23:18 GMT
server: GSE
{
"error": {
"errors": [
{
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
The strange thing is the auth works just fine for other API like calendar.
I'm not sure what i'm missing that would case this issue
A 401 Unauthorized and a 403 Forbidden are two different errors. But, make sure the Analytics service is turned on for your project in the API console: https://code.google.com/apis/console/.