I am trying to use Patrick’s Google2 plug-in from ServoyForge, but there is no sample solution or much in the way of documentation.
I am actually trying to use it to allow me to access the Google Analytics API’s which require ‘oauth2’, which it looks like this plugin uses.
I think I have set all of the Google stuff up correctly, so I can do the first bit
- Code: Select all
fv_ga_scopes = ['https://www.googleapis.com/auth/analytics'] ;
plugins.Google2.setupApplication('MYAPPNAME', scopes.globals.ga_client_id, scopes.globals.ga_certificate_fingerprint) ;
var _ga_url = plugins.Google2.getAuthorizationUrl(fv_ga_scopes) ;
//sets the relative URL of the HTML_AREA field
elements.html_area.URL = _ga_url;
where ‘elements.html_area’ is an HTML area I am displaying on a form.
This displays a Google page that seems to want a password entered & has a ‘Sign In’ button.
I enter my Google password and click button, but then nothing happens (& I do not get a token as the Google2 Wiki states)
I have also tried just opening the URL in a web browser using application.showURL, but then get an error page
The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob did not match a registered redirect URI.
Request Details
scope=https://www.googleapis.com/auth/analytics
response_type=code
redirect_uri=urn:ietf:wg:oauth:2.0:oob
client_id=
I am at a loss as to how to proceed, so was wondering, is there a sample solution or some code I can use to get me back the data I need for the token (from Wiki:-)
Once the user logged into his account and granted the requested access, he will be presented with a code (token). That token is then used to authorize your application:
plugins.Google2.authorize(code, userId, scopes)
Please not that the code has a validity, so it will expire rather quickly. The result of the method is the refresh token that you need to store.
so I can use the refresh token to make my GA calls??
Or if anyone else knows how I can get a token to call GA API's??
Thanks
Rafi