ChatFuel - Google Drive - Get file content using GET method via URL - google-drive-api

I am developing a Fuel chatbot that gets file's content from Google drive to build gallery.
I am using JSON API (Fuel chatbot) to get the JSON response.
My file in drive: https://drive.google.com/file/d/0Bx79Tkj95Q3iNmVHOFN0Q3BITE0/view
I want to get JSON response like:
{
"messages": [
{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Classic White T-Shirt",
"image_url":"http://petersapparel.parseapp.com/img/item100-thumb.png",
"subtitle":"Soft white cotton t-shirt is back in style",
"buttons":[
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com/view_item?item_id=100",
"title":"View Item"
},
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com/buy_item?item_id=100",
"title":"Buy Item"
}
]
},
{
"title":"Classic Grey T-Shirt",
"image_url":"http://petersapparel.parseapp.com/img/item101-thumb.png",
"subtitle":"Soft gray cotton t-shirt is back in style",
"buttons":[
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com/view_item?item_id=101",
"title":"View Item"
},
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com/buy_item?item_id=101",
"title":"Buy Item"
}
]
}
]
}
}
}
]
}
I tried to get the content of the file by URL:
https://www.googleapis.com/drive/v3/files/0Bx79Tkj95Q3iNmVHOFN0Q3BITE0/export?mimeType=application/vnd.google-apps.file
But I got the response
Do you have any suggestion to get the JSON response ?

Consider this documentation and test again.
Your error is:
403: Daily Limit Exceeded
The Courtesy API limit for your project has been reached.
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceeded",
"message": "Daily Limit Exceeded"
}
],
"code": 403,
"message": "Daily Limit Exceeded"
}
}
Suggested action: Request additional quota.
Based from the SO post, you may do the following to get rid of your error.
Create a Google APIs Console project
On the Services pane, enable all of the APIs that your project requires.
On the API Access pane, click Create an OAuth 2.0 client ID. A dialog opens. Fill in your project's information. Click
Next
Choose the appropriate application type. Based on the tags you used for this post, I am guessing this is an iOS project so select
Installed application.
Enter your bundle ID. You don't need to enter an App Store ID until your app is listed there.
Click Create Client ID.
You will see the client ID and client secret values. You will use
these values to enable communication with your project and the Google
APIs.
If you aren't already using it, see the Google+ iOS SDK and
documentation for a full walk through. The task called "write
moments" is similar in implementation and demonstrates how to connect
to and use the Google+ REST APIs from within an iOS project that uses
the SDK.
You'll need to specify the scope of plus.me to get the profile
information.
Hope this helps.

Related

Use appscript to track user installs of google marketplace app

We've developed a Google Marketplace app using AppsScript which we've now made live on the marketplace (https://workspace.google.com/marketplace/app/report_connector_for_salesforce_beta/977246938879). However, we're struggling to work out how to use the Google Marketplace API (https://developers.google.com/workspace/marketplace/example-calls-marketplace-api) to access the license data. Has anyone else successfully managed this?
Has anyone else managed to get this working? It would be great if there was an app for this by the way on the marketplace!
Many thanks
Andy
So far, we've created a separate Google Sheet (in the same domain as our app), and we've written a simple API call function as follows:
function getUsers() {
const options = {
muteHttpExceptions: true,
headers: {
Authorization: `Bearer ${ScriptApp.getOAuthToken()}`
}
};
let response = UrlFetchApp.fetch("https://appsmarket.googleapis.com/appsmarket/v2/licenseNotification/<our app Id>",options);
Logger.log("Refresh Response:"+response);
}
We've created a new project in the GCP, and have enabled:
Google Workspace Marketplace API
Google Workspace Marketplace SDK
We've added the following scopes to the project:
Connect to an external service https://www.googleapis.com/auth/script.external_request
View your installed application's licensing information https://www.googleapis.com/auth/appsmarketplace.license
But, when we run the code, we just keep getting the following:
Info Refresh Response:{
"error": {
"code": 403,
"message": "Not authorized to access the application ID",
"errors": [
{
"message": "Not authorized to access the application ID",
"domain": "global",
"reason": "forbidden"
}
]
}
}
This worked for me, but I needed to add "https://*.googleapis.com/" in the urlFetchWhitelist.
Is your App Id correct? Check it out at https://console.cloud.google.com/apis/api/appsmarket-component.googleapis.com/googleapps_sdk?project=*projectName*

Unable to access purchases.subscriptions API from developer console

I create IN app purchase for my product and I link google console application with androidpublisher consent
I am trying to call below API but its always fail
API to call :- https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/acknowledge?authuser=3
Error :-
{
"error": {
"code": 403,
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
"errors": [
{
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
"domain": "androidpublisher",
"reason": "projectNotLinked"
}
]
}
}

Unauthorized WebHook callback channel Google push notifications

I am trying to monitor my files in Google Drive.
By getting notifications to the delivery channel.
I've tried everything and tried hundreds of times but every time he tells me:
`
I am using Postman.
Post https://www.googleapis.com/drive/v2/changes/watch
Body:
{"id": "01234567-89ab-cdef-012345***789ab",
"kind":"drive#startPageToken",
"type": "webhook",
"address": "https://nwafith.com/api/notifications"
}
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://www.nwafith.com/api/notifications"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://www.nwafith.com/api/notifications"
}
}
In the Domain verification
I added:
www.nwafith.com
nwafith.com
Everything looks right but I don’t know exactly where the problem is.
I hope for help
Unauthorized WebHook callback channel:
Means that you have not properly authorized your domain in Google developer console.
Solution:
Go to the Google Developers Console
Select your project
Under 'APIS & AUTH' select 'Push'
Click 'Add domains'
Enter the needed domains (Only the domain is needed: https://www.nwafith.com)
Click the 'Add domains' button
After that it should work.

OAuth consent screen - ability to remove application logo: old solution is no longer working

Question: how to remove an application logo.
Solution: previous solution from this answer, https://stackoverflow.com/a/57168008/1992004, is no longer working.
Google changed the format of "iconUrl" to "icon", and uses now the Base64-encoded data stream, like "icon":"iVBORw0KGgoAAAAN..., instead of the image URL, previously written as "iconUrl":"https://...".
I've tried "icon":"" and many Base64-encoded values like "icon":"IA", "icon":"Lw", and some of other - no success. I get console messages like
for "icon":""
{
"error": {
"code": 400,
"message": "The request failed because one of the field of the resource is invalid.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "client_auth_config",
"subject": "?error_code=9&error_field_name=UpdateIconRequest.icon&error_field_value=%3CByteString#3eeee81e+size%3D0+contents%3D%22%22%3E"
}
]
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.ClientAuthConfigError",
"code": "ICON_STORAGE_FAILURE"
},
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.IconStorageError",
"reason": "INVALID_IMAGE"
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "icon",
"description": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \""
}
]
}
]
}
}
Does somebody know, what should be inserted here to remove the logo image from the app?
Answer:
Unfortunately, there is no way for this to be done.
More Information:
Once an OAuth Application Logo has been uploaded there isn't a supported way of removing it - in the question that you linked the way that this was done is a bit hacky, inspecting the network requests and building a new request from the previous JSON object sent via the UI really shows this.
As the icon URL has changed to need a Base-64 encoded value this has been deprecated. Whether this was intentional by Google or not is hard to say, but now an empty value will always return INVALID_ARGUMENT. Any data in the value for icon will also just replace the image data and so this isn't a viable workaround, as as far as the validation process goes, image data exists and so will need to be verified.
If it's not too much of a arduous process, the only workaround here is to create a new GCP project with a new OAuth consent screen without uploading an image. Of course, you will need to reactivate all the relevant APIs and link the relevant scripts and projects to the new set-up.
Feature Request:
You can however let Google know that this is a feature that is important and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services. I would suggest using the feature request template for G Suite Add-ons as this is a component for which GCP Projects could be used.
Update: The feature request for this is viewable here, to increase visibility on this, hit the ☆ at the top of the page.
Relevant Questions:
OAuth consent screen - ability to remove application logo [Obsolete]
May 2021 - It is still possible to completely delete the consent screen (and thus allowing to create it again). See my updated answer in https://stackoverflow.com/a/57168008/1992004

resourceData returns null for microsoft graph API webhook for Sharepoint Online

I am trying to set webhook notification for SharePoint Online drive using MS Graph API. The subscription is setup. Whenever I make any change in the drive by adding/deleting a file I get a notification but the resourceData is null.
Is this standard behaviour?
{"value":[
{"subscriptionId":"XXX",
"clientState":"secretClientValue",
"tenantId":"XXX",
"resource":"drives/<id>/root",
"resourceData":null,
"changeType":"updated",
"subscriptionExpirationDateTime":"2019-01-22T18:23:45.9356913+00:00"
}
]
}
Thank you for any suggestions.
Not all resources return resourceData within the notification itself, OneDrive is one of these.
OneDrive will return the following properties:
{
"subscriptionId": "string",
"expirationDateTime": "datetime",
"resource": "relative url",
"clientState": "string optional",
"changeType": "updated"
}
You can find the spesific documentation for this entity here.