Inapppurchases: get api query failed "code":400,"message":"Invalid Value" "code":500,"message":null - google-api

I get access_token by this way :https://developers.google.com/android-publisher/authorization
1.use google account allow acess get code
2.use code to get refresh_token
3.use refresh_token get access_token
when use this api
$url_purchase = "https://www.googleapis.com/androidpublisher/v1.1/applications".
"/$packageName/inapp/$productId/purchases/$token?access_token=".
$return_data->access_token;
$return_purchase = http_get($url_purchase);
some billing return
{"error":{"code":500,"message":null}}
some billing return
{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Value"}],"code":400,"message":"Invalid Value"}}
but some billing can success return
{"kind":"androidpublisher#inappPurchase","purchaseTime":"1395035642794","purchaseState":0,"consumptionState":1}
I think the access_token is right, why some billing failed . someone can help me ?thanks very much.
Are there any other way to check billing valid on the server?

Related

What does this Google API error message mean?

Imagine you call an API to get an in-app purchase details. It has 3 params: package name (de facto app ID), product ID and a purchase token.
You get the following response: HTTP 400 Invalid Value with JSON body like this:
[{'message': 'Invalid Value', 'domain': 'global', 'reason': 'invalid'}]
Is your package name invalid? Is your product ID invalid? Or is your purchase token invalid?
Hint: all of the values you passed are valid.
Question: what is wrong?
Answer: you're calling an incorrect API method. The purchase was not a product, it was a subscription.
I've wrote a ton of APIs myself and I would never ever return a HTTP 400 with such confusing output.
Google, you can do better.

Filter envelopes by email docusign

I need retrieving all the envelopes that have been signed or sent to an email.
I was trying to do this using the 'accounts/{account_id}/envelopes' endpoint passing the 'search_text' query param. As in the example in documentation https://developers.docusign.com/esign-rest-api/guides/concepts/envelopes/search
/v2.1/accounts/{account_id}/envelopes?search_text=Tabs
But I'm getting always error 400 - INVALID_REQUEST_PARAMETER. Am I doing this in the wrong way?
I think 4644 is most likely not your account ID. can you check what is your account ID?
Also, add :
&from_date=2019-03-04T00:00:00.000Z&to_date=2019-03-07T00:00:00.000Z

Pagination in Gmail API (Previous Token)

I have implemented GMail API which gets Emails for me. Now I am trying to add pagination to it I have succeed in getting next records but now I also want to have Previous option(which required previous token).
I am unable to get into it below is what I tried so far.
public function paginate(Request $request){
$label = $request->input("label");
$nextToken = $request->input("next");
$prevToken = $request->input("prev");
$messages = LaravelGmail::message();
$msg = $messages->take(3)->in($label)->all($nextToken);
$nextToken_New = $messages->pageToken;
return view('gmail.load_mails', ['messages' => $msg, 'nextPageToken' => $nextToken_New,
'prevPageToken' => $nextToken]);
}
Now In the above function nextPageToken is passed in view as $nextToken_New
and for prevPageToken I am unable to set previous page token.(In code I have set last nextPageToken to prevPageToken which is not working)
Remember prevPageToken will be used to set on back key.
The Gmail api does not support prevous page token. Its not going to return the value to you.
Your first option would be to save these tokens on your server and then when ever you want to go back a page simply supply the token you want to the page token field
The second option and the one that i personally feel would be the most logical. Would be to cache the data returned by these requests on your server so that
you dont have to make extra http calls to the server.
you are not eating addictal quota making a call you have already made before.
APIs were not meant for you to use to implement pagination in your application. You should only be requesting data once its your job to then cache that data so that you wont need to make the same request twice.

List Payouts of stripe Account

According to Stripe Payout API
I need to retrieve all payouts of a destination, So i made this request:
def all_payouts(external_account)
return Stripe::Payout.list(
:destination => external_account
)
end
from the API I tried to send the external_account(like "ba_XXXX") but it keeps returning
No such external account: ba_XXXX while testing it using Postman, I checked the external_account but it is exists on stripe.
Any help?
Since this is a common enough question and easy to miss that you solved it in the comments, here's the correct code to do this.
When trying to list payouts on a connected account, you have to make the API request authenticating as this account. You would pass the platform's Secret API key along with the connected account's id in the Stripe-Account header. In Ruby, the code would look like this:
payouts = Stripe::Payout.list(
{:destination => external_account},
{:stripe_account => "acct_XXXXXX"},
)

oauth2client.client - Received token response with no refresh_token. Consider reauthenticating with prompt='consent'

I received google auth code from mobile app and use python oauth2client to exchange to access token and refresh token as follow:
credentials = client.credentials_from_clientsecrets_and_code(
app.config.get('GG_APP_SECRET'),
['profile'],
authCodeFromMobileApp,
redirect_uri='http://example.com')
Then I received:
Received token response with no refresh_token. Consider
reauthenticating with prompt='consent'.
Based on this it said that I have to set: access_type=offline But I'm not really sure where/how in oauth2client to set this?
Anyone here ever solve this issue before?
Addition:
I have tried below as well:
flow = client.flow_from_clientsecrets(app.config.get('GG_APP_SECRET'),
['profile'],
message=None,
cache=None,
redirect_uri='http://example.com',
device_uri=None)
flow.params['access_type'] = 'offline'
credentials = flow.step2_exchange(req_gg_code, http=None)
But still having the same unexpected result...
flow_from_clientsecrets method has parameter called prompt which you can pass a value "consent"
flow = client.flow_from_clientsecrets(
app.config.get('GG_APP_SECRET'),
['profile'],
message=None,
cache=None,
redirect_uri='http://example.com',
device_uri=None,
prompt='consent'
)
Now, it will ask for Users consent every time, and you would get a refresh_token every time to use.

Resources