I would like to know if it is possible to call a Google API that requires auth such as the Google Calendar API using the Apache HttpClient, and no Google code or libraries. (and need the code to do it)
This is the code I have so far, its gets an auth error,
What do you use for the user/password?
HttpPost request = new HttpPost("https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey");
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(
new AuthScope(AuthScope.ANY),
new UsernamePasswordCredentials(user, password));
HttpResponse response = client.execute(request);
Error:
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
You don't use Login and password you need to be authenticated once you are you will have an access token then you can call something like this.
https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?access_token={tokenFromAuth}
You can authenticate to Google with any language that is capable of a HTTP POST and a HTTP GET. Here is my walk though of the Auth flow to Google http://www.daimto.com/google-3-legged-oauth2-flow/ you will need to create a Oauth2 credentials on Google Developer console to start. Then its just a matter of asking the user for permission to access their data and requesting the access.
Related
We have been using ShareFile API for downloading the Citrix Attachment. We are using Oauth 2.0. The general flow is - our clients will authorize the our Citrix ShareFile App to grant permission for accessing their files. OUr ShareFile app should already have the required permission\scopes because with the same app we are successfully downloading attachment files of our customers. However, we are having some problem with a client.
When we tried to get Share items of this client with the access token, we are getting the following error:
Request:
https://clientdomainname.sf-api.com/sf/v3/Shares(se552cbfffda144619419696b8b12f88b)/Items
Response:
{
"code": "Unauthorized",
"message": {
"lang": "en-US",
"value": "You must log in to view this link."
},
"reason": "NotAuthenticated"
}
And when we tried to refresh the access token, we got the Bad Request (error code 400) with invalid_grant error using the refresh token
Request:
https://clientdomanname.sharefile.com/oauth/token
Response:
{
"error": "invalid_grant"
}
Any help would be highly appreciated!
I'm trying to use your AMADEUS API but i have trouble to display hotels offers on production environment ..
Note that everything is ok on sandbox.
On https://api.amadeus.com endpoint I do :
/v1/security/oauth2/token to get an access token
then add the access token as bearer authentication
Then launch the request /v2/shopping/hotel-offers/?cityCode=NCE
((( Same as the sandbox )))
Here the response :
"errors": [
{
"status": 401,
"code": 701,
"title": "Wrong authentication credentials.",
"source": {
"pointer": "uri"
}
}
]
So I test the token on /v1/security/oauth2/token/{{XXXXXXXX}}
The token is not expired and approuved.
Anyone to help?
Thank you so much (sorry for english mistakes)
Akim
I am trying to translate some text using GCP translation service with REST api https://translation.googleapis.com/v3
I'm using API key auth method.
url and
Body
https://translation.googleapis.com/v3/projects/my-translator-1122333:translateText?key=thisismykey
{
"content": ["Hello"],
"sourceLanguageCode": "en",
"targetLanguageCode": "ru"
}
However I got
{
"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"
}
}
Could anyone explain me what is wrong I do?
Thanks
I am new to YouTube Analytics API.
Could you please help me to retrieve data from my associated YouTube channel.
I have populated the data using “youtubeAnalytics.reports.query” in the APIs Explorer window.
But when I am trying to use the below HTTP request
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3D{MY_ASSOCIATED_CHANNEL_ID}&start-date=2016-08-01&end-date=2016-08-31&metrics=views&dimensions=video&filters=video%3D%3D{MY_VIDEO_ID}&max-results=10&sort=-views&key={MY_API_KEY}
It shows an error message “Login Required”
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Could you please help me to correct my HTTP request to populate the data.
Thanks,
Aneesh
As far as I know most all of the YouTube Analytics API is private data. Being that its private data you need to be authenticated in order to access it.
Your error "Login Required" means exactly that you need to be authenticated to access the data you are requesting. Probably using the scope
https://www.googleapis.com/auth/yt-analytics.readonly
Once you have authenticated your application you can do access_token={Access token gotten from authentication} in order to access that data.
Using OAuth code i am able to generate access token for google+ API .
using this access token in oauthpalyground iam getting JSON response .
When I paste this this URL into a browser am get an error message.
https://www.googleapis.com/plus/v1/activities?query=%22great%22&access_token=xxxxxxxxxxx
Error Message
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Can anyone explain to me why?
You can not query directly from browser sending the access_token as a querystring. You must send access_ token in headers this way:
Authorization: Bearer <access_token>
Try it with Fiddler or some similar software.