Hello Matt, Thanks for answered
I already tried this one.
I'm developing in C# I got the connection by server side but using ;
Johnvey.GmailAgent;
or / and
But for both still not working for my code by on client side...
I've been trying
this... but need to be log in a google account
<script>
gapi.analytics.ready(function () {
gapi.analytics.auth.authorize({
container: 'embed-api-auth-container'
});
var dataChart1 = new gapi.analytics.googleCharts.DataChart({
query: {
'ids': 'ga:8600000',
'start-date': '30daysAgo',
'end-date': 'yesterday',
'metrics': 'ga:sessions,ga:users',
'dimensions': 'ga:date'
},
chart: {
'container': 'chart-1-container',
'type': 'LINE',
'options': {
'width': '100%'
}
}
});
dataChart1.execute();
});
$("#embed-api-auth-container").hide();
</script>
and... this one...
<script>
gapi.analytics.ready(function () {
var pheader = { "alg": "RS256", "typ": "JWT" }
var sheader = JSON.stringify(pheader);
var pclaim = {};
pclaim.exp = KJUR.jws.IntDate.getNow();
pclaim.iat = KJUR.jws.IntDate.getNow();
var sclaim = JSON.stringify(pclaim);
var pass = "xxxxxxvW-uhTnFAnzenc2pQ";
var sjws = KJUR.jws.JWS.sign(null, sheader, sclaim, key, pass);
var xhr = new XMLHttpRequest();
var urlencodeddata = "";
var urlencodeddatapairs = []; urlencodeddatapairs.push(encodeURIComponent("grant_type") + '=' + encodeURIComponent("urn:ietf:params:oauth:grant-type:jwt-bearer")); urlencodeddatapairs.push(encodeURIComponent("assertion") + '=' + encodeURIComponent(sjws)); urlencodeddata = urlencodeddatapairs.join('&').replace(/%20/g, '+'); // define happen if info sent
var token = "";
xhr.addEventListener('load', function (event) {
var response = JSON.parse(xhr.response);
token = response["access_token"];
});
//gapi.analytics.auth.authorize({
// serverAuth: {
// access_token: token
// }
//});
xhr.addEventListener('error', function (event) {
alert('oops! went wrong.')
});
xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
xhr.send(urlencodeddata)
});
</script>
The second one brings me the token but when i tried to use for:
gapi.analytics.auth.authorize({
serverAuth: {
access_token: token
}
});
doesn't work.
have you ever try this? do you have any idea what can be?
already lost 2 weeks on it.
=(
Best regards