Recently, for some unknown reason, our google analytics API's are not functioning properly. I know the issue revolves around some account deletion. For instance, here is the code for refreshing the access token:
uri = URI.parse('https://www.googleapis.com/oauth2/v4/token')
params = {
client_id: client_id,
client_secret: client_secret,
refresh_token: token,
grant_type: 'refresh_token'
}
headers = {
'Content-Type' => 'application/x-www-form-urlencoded'
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
post_request = Net::HTTP::Post.new(uri.path, headers)
query = URI.encode_www_form(params)
post_request.body = query
response = http.request(post_request)
The response is returning this:
#<Net::HTTPBadRequest 400 Bad Request readbody=true>
response.body = "{\n \"error\": \"invalid_grant\",\n \"error_description\": \"Account has been deleted\"\n}"
I am having a hell of a time figuring out how to fix this issue. What account do I need to recreate? A Service account? The documentation is really unclear.