Google Documents List API - problem retrieving a list of documents - google-api

I'd like to get a list of my documents from google docs api. First I get a authValue using ClientLogin, then I send a request to that url https://docs.google.com/feeds/documents/private/full with header set to "Authorization: GoogleLogin auth=authValue", but I always get a response "Authorization required". What should I do?

Make sure you request the token with the "writely" service when performing ClientLogin. Also, make sure that you're sending the token provided after Auth= in the ClientLogin response.
Authorization: GoogleLogin auth=DQAAA...

Related

Swagger-Net and Bearer Token Authorization

We are using Swagger-Net with Bearer Token Authorization as follows:
c.ApiKey("Authorization", "header", "Bearer Token Authentication");
The request needs to be sent in the format "Bearer [bearertoken]", and I have verified this does work correctly when pasted in this format into the "API Key" authorization textbox. The Curl shows it being passed in the header as -H "Authorization: Bearer [token] and the API request succeeds.
Is there any way to automatically send a known token along with every API request? Or asked another way, is there any way to pre-fill this dynamically created API Key textbox with a known string to simplify the process for the end using testing our API?

401 Unauthorized on Google Photos API with API Key

Trying to build an Angular 6 application to display all photos from a particular Google Photos album. Before implementing the Angular portion, I wanted to see if I could get the data from a cURL command, using the API key I created and gave access to the Photos API.
cURL:
curl -X GET \
'https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=1&key=[API KEY]' \
-H 'Accept: application/json' \
This is based on the samples from Google's documentation here: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list
However, adding my valid API key results in the following error:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Is there additional data required besides the API key to get this working? Is it even possible to use an API key in this manner, or does it require using OAuth 2.0 and all the additional hoops that come with it?
You need to obtain an OAuth AccessToken to add as an HTTP Header in your request.
Here's a breakdown of the process I've used that has worked, with the caveat that it periodically gets 401 errors from the mediaItems requests. It seems that Google is throttling the requests and denies a few if they're coming too fast.

how to attach the token in the header by automation script in postman

I am trying to automate API testing using Postman. Apart from AuthAPI every other API is decorated with [Authorize] so I need to pass token.
In my collection, the first API is AuthAPI, This API returns the JWT token.
if I run the API in collection runner, I am getting 403 error for all the APIs in the collection.
However, If I do manually copy the token recieved in the AuthAPI resonse & paste in the Authorization header, it returns the desired response.
How do I attach the token received in the response of the AuthAPI in the header of the subsequent request (Postman) when running the API in the Automated way.(via Collection Runner)
Thanks
You can use the environment variable to store the token an use them in the subsequent request. Also, the first request should be Auth API.
Check the postman console for the request details, You might have encountered the issue similar to this thread. Check whether the header has bearer or Authorization in the request details.
use variables inside Postman and Collection Runner
http://blog.getpostman.com/2014/02/20/using-variables-inside-postman-and-collection-runner/

How to pull pubsub metrics from google api

We are using our own logging solution because stackdriver is su...bpar. I want to pull the metrics on how many unacknowledged messages there are in the pubsub. Started to read the docs on that and they are all over the place.
Found this page:
https://cloud.google.com/monitoring/api/metrics
Despite being under the api it does not describe any api calls, but does contain the description of the metric I want to extract.
Now I am thinking I need to use the monitoring api to extract what I need somehow:
https://cloud.google.com/monitoring/api/ref_v3/rest/
So I use the api explorer to try a couple of methods:
https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
I query and gives me an available url:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
I go to my project's console (api & credentials page) and generate an api key without restrictions and paste it in trying to curl.
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Why is this happening? How can I get the metrics? I went to the url provided but it explains oauth token creation and has nothing regarding the api keys. I just need to curl things to make sure I am going the right way.
Why does this have to be so hard? Killed several hours of my life trying to get this.
curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups

How to send auth_token in Http header

I am trying to create rest based webservices, which I want to secure them using spring security Oauth2.
What I found is then, in oauth2 we have to send auth_token in query string.
But my need is to send in header.
I have searched a lot, but I didn't get the answer which I need.
Is there anybody who can help?
Reference link [ http://www.beingjavaguys.com/2014/10/spring-security-oauth2-integration.html
]
You can test sending the access token for example using Curl:
curl -H "Authorization: Bearer <ACCESS_TOKEN>" http://www.example.com
With this you should be able to see, if server is working as expected. How to do it in client application depends on the programming language you are using.

Resources