403 Forbidden error with Google URL shortener API when accessing public data - google-contacts-api

I'm trying to expand a public short url using the Google URL Shortener API. The Google URL Shortener API is discontinued from March 30th as described in this blog post. Instead I should be using Firebase Dynamic Links but I can't find any docs on expanding URLs with FDL.
I'm only accessing public data so I have been using the shortener URL api with only an API key:
curl https://www.googleapis.com/urlshortener/v1/url\?shortUrl\=https://goo.gl/maps/JtZ2Yq19vJP2\&key\=MY_API_KEY
I always get the following response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
When using the API explorer I'm getting the same response so I'm assuming it's because the API is being discontinued so how can I use Firebase Dynamic Links to do the same?

I am also had same issue since last week. I searched for solution but the reason is Google is shutting down its goo.gl URL shortening service.
https://www.engadget.com/2018/03/30/google-shutting-down-goo-gl-url-shortening-service/

Related

Enumerate files in gogle team drive where admin is not part of

I would like to know if a Google drive domain admin can enumerate files in team drive where he is not a member? currently this seems not supported through drive rest api, I'm using below API call to enumerate files and the corresponding error response below. Please let me know if there is any alternative api call to achieve this.
https://www.googleapis.com/drive/v2/files?teamDriveId=&corpora=teamDrive&fields=*&includeTeamDriveItems=true&supportsTeamDrives=true
{
"error": {
"errors": [
{
"domain": "global",
"reason": "teamDriveMembershipRequired",
"message": "The attempted action requires Team Drive membership."
}
],
"code": 403,
"message": "The attempted action requires Team Drive membership."
}
}
You must take note of the following Team Drives: Requirements & access levels before making any requests to Drive API.
Users with G Suite Basic cannot create or access Team Drives
unless they are invited by a member of an external organization that
has Team Drives.
Refer to the table below on what action you can do in every team drives if you are a member.
To learn more about Drive API methods, you can refer to the Drive API documentation.

exportlink for Google drive api v3

I'm switching to the Google drive V3 apis and I'm not able to retrieve the stream to the document.
Goal: I want to push a google drive document to another location and I need to retrieve the stream of the file in order to use it to push it to the target.
I can't find a way to do it using Google Drive API V3 !
In V2, I used:
downloadUrl = file.ExportLinks[(string)ExportTable[file.MimeType]];
And then I could use something like:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(downloadUrl));
I don't find the equivalent in V3.
I tried:
var getfile = _service.Files.Get(file.Id).Execute();
var request = _service.Files.Export(file.Id, getfile.MimeType);
System.IO.Stream stream = request.ExecuteAsStream();
And the content of the stream is:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fileNotExportable",
"message": "Export only supports Google Docs."
} ],
"code": 403,
"message": "Export only supports Google Docs."
}
}
Of course, we don't want to download it to a local file and then generate a new stream from the file cached locally. We want to remain entirely in memory.
Thanks for your help
You can see that in the Migrate to Drive v3 docs, it says that:
The exportLinks field has been removed from files. To export Google
Documents, use the
files.export
method instead.
Check that page for other changes in v3 as well.
You can also create a link yourself if you are logged in as the right user or the file is public with a link:
https://docs.google.com/feeds/download/documents/export/Export?id={{ID}}&exportFormat=pdf

How do I enable Google Maps Tile API?

I found out from here that there is a Google Maps Tile API (official documentation here).
However, I can't seem to find a way to enable this API.
Except for the link found in the question mentioned above, I couldn't find any other reference to this API, anywhere. It's not even listed on the main page of the Maps API (here) or the documentation page.
The API is also not listed in the Developer Console API Library.
I've tried sending a session request (as explained in the documentation) but received this response:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Maps Tile API has not been used in project XXXXXXXXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tile.googleapis.com/overview?project=XXXXXXXXXXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"extendedHelp": "https://console.developers.google.com/apis/api/tile.googleapis.com/overview?project=XXXXXXXXXXXX"
}
],
"code": 403,
"message": "Access Not Configured. Maps Tile API has not been used in project XXXXXXXXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/tile.googleapis.com/overview?project=XXXXXXXXXXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
}
}
Following the link to the Developer Console, I receive this message:
The API "tile.googleapis.com" doesn't exist or you don't have
permission to access it
Is this a Google Maps premium feature? Does any one have more information on this API?
The Tile API is not available for Standard plan users. Neither for Premium plan users [1]. It requires a special license. You should contact Google's sales team directly in order to get some additional information regarding Tile API.
[1] https://developers.google.com/maps/premium/overview#package

Google Cloud KMS error - This API is not acessible from your region. (HTTP status - 403)

I have created a google cloud project and enabled Google Cloud Key Management Service (KMS) API. I have created two keyrings. keyring1 is located in us-east1 and keyring2 is located in global. I have created the following java program to list the keyrings in the region:
GoogleCredential credential = GoogleCredential.getApplicationDefault();
credential = credential.createScoped(CloudKMSScopes.all());
String keyRingPath = "projects/<<projectId>>/locations/global";
CloudKMS kms = new CloudKMS.Builder(httpTransport, jsonFactory, credential).setApplicationName("CloudKMS snippets").build();
ListKeyRingsResponse response = kms.projects().locations().keyRings().list(keyRingPath).execute();
System.out.println(response.getKeyRings());
I am getting following forbidden error:
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "This API is not acessible from your region.",
"reason" : "forbidden"
} ],
"message" : "This API is not acessible from your region.",
"status" : "PERMISSION_DENIED"
}
I'm an engineer working on Cloud KMS.
Unfortunately, there are many complexities in making this service available in individual countries and we don't have a specific timeline as to when or if any particular country will be rolled out.
Anyone who is interested in the availability of a particular country should contact us to see if any information is available and to help us prioritize.
I am trying to invoke the Cloud KMS APIs from India. Looks like Cloud KMS is not yet available in all the locations. Cloud KMS service is not yet available in India. Click here to know the list of countries where Cloud KMS is available. That is why I was getting the This API is not acessible from your region. error

Google Drive Realtime API "get" endpoint not working as expected

We are trying to use the Google Drive API to retrieve the model of a Realtime document (API reference). However, if I call the "get" method to retrieve details of a Realtime File generated through the Google Drive Realtime API Playground app (with a blank "revision" field), the result is always:
{
"appId": "292824132082",
"revision": 1,
"data": null
}
even after a lot of editing on the model. If I try to specify a different revision (say, "2") the result is a 500 error:
{
"error": {
"code": 500,
"message": null
}
}
Are we doing something wrong or is there a problem with this specific API?
Calling "get" using the API Playground gets the realtime document associated with the API playground app, not the realtime document associated with your app.
If you update and get both with the API playground you should see contents.