Google Script Oauth v1.0 REST API access - javascript

I need a way to access a Oauth v1.0 rest API form inside google script. google apps script.
I found this page
It says that the Library was sunset in 2015. I tried to add it. When I do I get an error that it's not supported anymore and my script refuses to run.
Error:
Exception: ScriptError Exception: Script is using OAuthConfig which has been shut down. Learn more at https://cloud.google.com/blog/changes-oauth-apps-script [ { function: 'test', lineNumber: 80 } ]
I need to access a external site to download some data. I'm trying to access the data in Gravity Forms.
They are using Oauth v1.0.
I'm able to access the data fine using Postman / Oauth v1.0. However I am unable to find a solution for google apps script.
Can anyone point me in the right direction to get Oauth v1.0 working? Possibly a fully JS option?

The documentation says
The URL Fetch service's OAuthConfig class provided a simple mechanism for connecting to an API that utilized OAuth, specifically OAuth versions 1.0 and 1.0a. This mechanism was sunset on July 6, 2015. The open source library OAuth1 for Apps Script was created as a replacement, and this page will demonstrate how to update your scripts to use this new mechanism.
The mechanism that was sunset was UrlFetchApp's addOauthService method(Class OAuthConfig).
The replacement provided is a open source library here
This library is officially recommended and updated regularly.
Warning: Google's OAuth 1.0 support was deprecated in 2012 and is scheduled to be shut down on April 20, 2015. Scripts using OAuthConfig to connect to a Google API should instead use the OAuth2 for Apps Script library.
This shudown refers to Google's own oauth 1.0 support for Google apis, such as Google maps api or Google drive api and does NOT refer to all third party apis

Related

Google Sheets API javascript quickstart uses obsolete Google Sign-in Platform Library, how can I use Google Identity Services library

Is there a modern version of the quickstart?
Google sheets javascript quickstart
Using google's code will display their own error in the browser console:
Your client application uses libraries for user authentication or authorization that will soon be deprecated. See the Migration Guide for more information.

Google App Engine: API is not being called in deployed version

I am building a web app with Google AppEngine. I am using the Google Maps, Google Places, and Geocoding API's.
In the local version, everything works as it should. When the page is loaded, the user's current location is indicated and all the nearby stores are marked with markers on the map that appears on the webpage.
In the deployed version, only the map loads. I checked the console developer's log on Google and I noticed that a request to the Google Maps API is made, but not to the Google Places or Geocoding API's. I'm really confused/not sure what's going on. I tried browsing through some old questions, but I can't figure out how to fix this. If anyone could offer a solution, I would greatly appreciate it.
** I have made sure that the deployed version is the most recent version. It 100% works on localhost, but doesn't on the deployed webpage.
Edit: the API's aren't being called because they don't work on "insecure origins". I've configured the app.yaml under handlers to be
- url: /.*
script: IGNORED
secure: always
but it doesn't seem to make a difference.
You don't have to separately call Google Places and Geocoding APIs. All those are included in the Google Map API. If you want to choose on what you should include in your map click here to refer the API on customizing your map.
By default, Google App Engine doesn't support secure connections, which both the Geolocation & Google Places API's need, in order to be called. However, Google App Engine can support secure connections. The local host does support secure connections, which is why the local version of my app was working.
To properly support secure connections after deploying the app, just add in the parameter "secure: always" in the app.yaml file under Handlers!

Access Not Configured. The API (Google+ API) is not enabled for your project. Please use the Google Developers Console to update your configuration

Giving error even I enabled Google+ API in Google Developers Console
Code:403 "message": "Access Not Configured. The API (Google+ API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
You have not enabled the Google+ API for your project in the Google Developer console. Make sure that its enabled and double check that your code is using the correct client_id and clientsecret, that match this project. My tutorial on how to enable APIs in Google Developers console.
Where to enable it:
Go to the Google developer console on the left look for the Apis & Auths menu under that you will find the API menu.
APIs & auth -> API
Look for Google+ API enable it.
I found there to be about a 30 minute delay between enabling the API and it allowing me to make calls.
To speed this up I needed to run an API explorer query like this:
https://developers.google.com/apis-explorer/?hl=en_US#p/calendar/v3/calendar.calendarList.list
But it may have been a coincidence :)

Configure CORS when accessing AWS ELB service using AWS-SDK-JS

I'm working on a ELB monitoring application that I'd like to build with JS and host directly in S3. I have no experience of JS and I'm struggling to get to grips with CORS.
I have successfully created a build of the SDK for my browser (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-building.html) which includes ELB API support.
I have integrated Amazon login (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-configuring-wif.html) with my script and I have attached it to an IAM WebIdentity role.
When I call
elb.describeInstanceHealth(elbRequestParams).on('success', describeInstanceHealthCallback).send();
I get an error in Javascript console
XMLHttpRequest cannot load 'elasticloadbalancing.eu-west-1.amazonaws.com/'. The request was redirected to 'aws.amazon.com/elasticloadbalancing', which is disallowed for cross-origin requests that require preflight.
I can't find any clear documentation that what I'm trying to do won't work, but, I'll admit I'm confused by some of the terms in the documentation and I have no experience of CORS in previous applications to fall back on. I would think the whole JS-SDK for the browser is a bit redundant if the majority of services aren't CORS aware and need to be.
I can get this working by disabling web-security in my Chrome browser, obviously this isn't a good workaround but would indicate to me that CORS is the issue.
Is anyone familiar with this approach, is it a problem that I'm hosting on S3, or, would I have this problem from any server? Should I be configuring my S3 bucket with CORS, or, is it that there's no CORS policy on the 'elasticloadbalancing.eu-west-1.amazonaws.com' endpoint?
Thanks
Andrew
I have successfully created a build of the SDK for my browser (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-building.html) which includes ELB API support.
The referenced page already provides the first clue towards the lack of CORS support for elasticloadbalancing.eu-west-1.amazonaws.com you correctly suspect to be the cause here:
If you are working with the SDK outside of an environment that
enforces CORS in your browser and want access to the full gamut of
services provided by the AWS SDK for JavaScript, it is possible to
build a custom copy of the SDK locally by cloning the repository and
running the same build tools used to generate the default hosted
version of the SDK.
That is, the main reason for the official AWS SDK for JavaScript in the Browser excluding all but the currently 5 services listed in section Supported Services within Working with Services in the Browser is their lack of CORS support:
It is possible to use the SDK with other services if CORS
security checking is disabled in your environment. In this case, you
can build your own custom version of the SDK. See the Building the
SDK section of the guide for more information on how to create a
custom build of the SDK.
Unfortunately neither Amazon EC2 nor Elastic Load Balancing currently offers CORS support, see e.g. this recent Feature Request (CORS support for EC2 service), where the author rightfully reaches the same conclusion as you did already (while also hinting on Node.js to be another major use case, which supports all available AWS services, see Working with Services in Node.js):
From my point of view if AWS is providing a aws-sdk-js library all AWS services supported by this library should support CORS so that the aws-sdk-js iibrary is not just useable in a node.js environment but also in a browser.
While I agree in principle and would have expected faster turnaround times on this myself, AWS is well known for an agile approach to product development, i.e. start early with a small feature set and improve over time based on customer feedback. Notably the SDK is labeled Developer Preview only, i.e. not even BETA yet and I'd hope this to be addressed in the future accordingly - admittedly this is easily overlooked and a more prominent warning might go a long way in sparing users the time to figure out this limitation by themselves.

trigger.io — Google Analytics

How does one go about including Google analytics for Trigger.io-built apps? I can see that the mobile web built with trigger.io would be just a matter of embedding the GA JS code. But what about iOS or Android?
We have integrated the Flurry Analytics SDK as of our v1.4.19 platform release. Documentation available here:
http://docs.trigger.io/en/v1.4/modules/flurry.html
It is also possible to integrate the Google Analytics native SDK (or any other analytics SDK) using the plugin system.
Simple answer:
You already answered your own question - embed the Google GA JS code.
Alternative answer:
Another alternative is that you could utilize forge.ajax and fire the .trackPageView method in the success callback. In this case you would have to add the proper domain permission in your config file.
However, isn't GA tied to a specific domain (or group of domains)? In the case of PhoneGap or trigger.io there is no domain name.
Also, see this question & answer -
Step by step to get Google Analytics working in PhoneGap 1.2.0 on iOS (phonegapalytics)
Embedding the JavaScript version of Google Analytics won't work - for some reason, the tracking calls don't fire any events, so you need to use the measurement API.
I've created a plugin that allows you to use Google Analytics with Trigger.io on github, which you can use: http://bit.ly/1F3VM1J
The plugin uses the Request and Prefs module to send analytics data to Google, and it works with the realtime dashboard too. You can track screenviews and events only at the moment, but it should be sufficient for your application.
To track a pageview, you can do the following:
// send screenview tracking data
ga('send', 'screenview', 'App Load');

Categories

Resources