AccessTokenRefreshError : Gdata Spreadsheet API with Service Account - google-oauth

First some background, Using Service Accounts with GData Spreadsheet API for an app installed via Google Apps Marketplace.
credentials = SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
PRIVATE_KEY,
scope = SCOPE,
sub = "admin#domain.com")
auth2token = gauth.OAuth2TokenFromCredentials(credentials)
client = SpreadsheetsClient()
auth2token.authorize(client)
q = SpreadsheetQuery(title= "ItemMaster",title_exact=True,)
feed = client.get_spreadsheets(query = q)
The problem is that the API calls fail randomly with,
AccessTokenRefreshError: Invalid response 403.
Failed to retrieve access token: You are not authorized to perform this request.
I tried doing a test in which 10 API calls are made one after another with 1 second intervals between them, atleast 4 API calls failed with the above error.
I tried checked the quota on API console and that is not being exceeded, Per user limits on the API are at 100 requests/user/second for the Drive API, and billing is enabled.
PS: This question is different from Getting AccessTokenRefreshError: invalid_grant in Google API fro service account and Google API Python Client - AccessTokenRefreshError which are related to invalid_grant while my issue is specifically related to Random Failures of API calls
EDIT: The problem seems to be related to #210 in google-api-python-client

Related

Generating Google Pay Token without UI

We have a use-case where we need to authorize a payment using a native payment on the web but use two different merchants. We want the user to press pay with Google and go through the ui but access google pay api with two different merchants. paymentsClient.loadPaymentData(paymentDataRequest).then(function(paymentData){ // if using gateway tokenization, pass this token without modification paymentToken = paymentData.paymentMethodData.tokenizationData.token; }).catch(function(err){ // show error in developer console for debugging console.error(err); });
is it possible to get the callback from this api request without a user interaction for the second request.

Distributing API calls to users for web app

We are trying to call one of Google's APIs and analyze the data and then display it for the user on our site. We realize we can make calls to the API through our server using php or python, but because of Google's limit, we are looking for an option that will have the API call come from the user, instead of our server. Is there a way for a web app to distribute the requests amongst the users instead of make all the calls from our server?
Thank you very much as this has been a tricky one to Google.
I highly doubt that this is possible. The API request is per API key and you can't provide every user with their own API key.
If the scenario you are trying to achieve requests possibly the same data for multiple users. I highly suggest you save/cache the API request. This will minimize the times your server send API request to google since you saved that request to your server. You can then set an expiration for your saved/cached API request to renew X days.
Scenario
user 1: request data for item 123 from API.
server: sends request to API server, and save
user 2: request data for item 123
server: return saved API response

Get historical data using Instagram API endpoints.

I am trying to fetch data using the Instagram API endpoints. Steps that I have followed
1. Register the client app.
2. Got the access token.
3. I am using this access token through out the url endpoints.
Ex. to get the data for recent media I am using this url endpoint: https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN
However as I am in Sandbox mode, as per the documentation I get only the recent 20 media. Whereas my account contains in total 291 media.
Problems that I am facing:
Not able to get next_url in the paginationpart.
Usage of min_id and max_id in the url does not respond to any changes in the output or the data i.e fetched (Still get only 20 records/media)
Ex: https://api.instagram.com/v1/users/self/media/recent?access_token=XXXXXX&min_id=xxxxxx_xxxxx&max_id=xxxxxxx_xxxxxxx
Can anybody provide a solution as to how exactly I should get all of my historical data ?
You're in the sandbox mode so there's no way to achieve what you're trying to do before your app has been reviewed and approved (and gone live). From Instagram API documentation:
After your app has been reviewed and approved, you are ready to make it available to the general public. To switch your client from sandbox to live mode, you can use the button on the top section of the configuration screen for your app. When you are live, any Instagram user will be able to authorize your app, but you will have access only to the permissions that you were granted during the review.
Well, maybe you should try this library that allows you to scrape public info withou auth (client_id or access_token): https://github.com/raiym/instagram-php-scraper
$medias = Instagram::getMedias('kevin', 150);

Soundcloud API returns 0 tracks for user

For a client of mine I used the Soundcloud API to show tracks on his website.
now it had stopped working, the API returns 0 tracks.
https://api.soundcloud.com/users/1525250/tracks?client_id=dec73200bd1c369969eb9df50f4a190b
I checked his account and all tracks have the right permissions.
,
What am I doing wrong?
(website of client) eelkekleijn.nl
All rate limits on the SoundCloud API are currently calculated against a client application's client id so you need to change your application client id
Read More
Eg.
https://api.soundcloud.com/users/1525250/tracks?client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea
SoundCloud allows certain users to block API requests. In this case, this user has blocked the ability to view their information via the SoundCloud API.
The only way around this is to use an API Key internal to SoundCloud, such as the one youtube-dl uses to download tracks.

Soundcloud API not recognizing "Soundcloud Go" subscription

I just upgraded my account to the "Soundcloud Go" subscription and the API does not acknowledge the subscription:
Sample data from /Me endpoint
plan:"Free"
...
subscriptions:Array[0]
I gave it some time to refresh, I disconnected my account and re-connected it with a new access token with no different end result.
I was attempting to see if upgrading the account would allow greater access via the API as large portions of previously available data is now missing (for example I am only getting 42 of my "liked / favorited" items returned out of 62)