Coinbase API Invalid Report Type Using Docs Generated Body - coinbase-api

I am trying to create a report using the Coinbase API. I am pulling the request body from the documentation's generated curl. I am getting an error in the response.
request:
const result = await sendRequest('/reports', 'POST', {
"start_date": "2016-01-0100:00:00.000Z",
"end_date": new Date().toISOString(),
"type": "account",
"format": "csv",
"account_id": "ALL",
"product_id": "ALL"
});
response snip:
"status":400,"statusText":"Bad Request","body":{"message":"invalid report type"}
Regardless of what I set the type to in the body, I get this same error.

Related

How To Get Google User Profile Info Using Access Token From OAuth?

I am using ReactJS on the frontend: I successfully retrieved the access token from Google's Oauth service, but it doesn't give me any profile information for the 'current user'.
I tried using the /userInfo endpoint, ?access_token={my_access_token} query str, and some other solutions but I keep getting weird errors.
Currently I have:
const { access_token, refresh_token } = res.data; // now I have valid access_token
let userInfo = await axios.get("https://www.googleapis.com/oauth2/v3/userinfo",
{
headers: {
Authorization: `Bearer ${access_token}`
}
}); // ERROR WHEN MAKING THIS CALL.
My specific 401 error is as follows:
If there are better ways of getting user info (such as first/last name, email, etc. some sort of unique ID) please let me know.
You shouldnt rely on the user info endpoint to get user profile informaiton. As long as you are requesting the profile scope from the user, or even email. you should go though the People api. This will give you access to all of the users profile data.
GET https://people.googleapis.com/v1/people/me?personFields=names HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
response
{
"resourceName": "people/117dd2004755326722775346",
"etag": "%EgUBAi43PRoEAQIFBddyIMR3BzQkR2cnI1ZGc9",
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "117200155326727753146"
}
},
"displayName": "Linda Lawton",
"familyName": "Lawton",
"givenName": "Linda",
"displayNameLastFirst": "Lawton, Linda",
"unstructuredName": "Linda Lawton"
},
{
"metadata": {
"source": {
"type": "CONTACT",
"id": "3faa96eb0118baa4be"
}
},
"displayName": "Linda Lawton",
"familyName": "Lawton",
"givenName": "Linda",
"displayNameLastFirst": "Lawton, Linda",
"unstructuredName": "Linda Lawton"
}
]
}

Change value from api response React

From a request call to the marvel API I receive the following
{
"id": 1011334,
"name": "3-D Man",
"description": "",
"modified": "2014-04-29T14:18:17-0400",
"thumbnail": {
"path": "http://i.annihil.us/u/prod/marvel/i/mg/c/e0/535fecbbb9784",
"extension": "jpg"
},
How can I change the thumbnail.path to be https instead of HTTP because when I deploy the app I get the warning of mixed content saying it will be change automatically
You can change the value of response after response received. for example:
axios.get('/post?ID=12345')
.then((response) => {
const modifiedResponse = response.data;
modifiedResponse.thumbnail.path =
modifiedResponse.thumbnail.path.replace("http", "https");
// I see you tagged react
this.setState({post: modifiedResponse});
})
Please share more code if it seems my answer is ambiguous.

Discord api ignores the 'file' element

I've got a problem with using requests in python to upload files.
non-working code:
import requests
url = 'https://discord.com/api/v9/channels/XXXXX/messages'
headers = {
'authorization': 'XXXXX'
}
data = {
'file': open('test.png', 'rb')
}
r = requests.post(url=url, headers=headers, data=data)
print(r)
print(r.text)
This is the response I get:
<Response [400]>
{"message": "Cannot send an empty message", "code": 50006}
so I tried adding to data "content": "Whoas"
data = {
'file': open('test.png', 'rb'),
"content": "Whoas"
}
Which will now at least send the message, but without the file.
Here's the response I get:
<Response [200]>
{"id": "XXXXX", "type": 0, "content": "Whoas", "channel_id": "XXXXX", "author": {"id": "XXXXX", "username": "XXXXX", "avatar": "XXXXX", "discriminator": "2885", "public_flags": 0}, "attachments": [], "embeds": [], "mentions": [], "mention_roles": [], "pinned": false, "mention_everyone": false, "tts": false, "timestamp": "2021-05-22T09:08:47.061000+00:00", "edited_timestamp": null, "flags": 0, "components": [], "referenced_message": null}
I'm most likely just not understanding the discord API documentation (https://discord.com/developers/docs/resources/channel#create-message), which unfortunately doesn't go into detail about how to upload a file.
I've tried using the module discord.py with discord.File('test.png') but this method isn't giving back the link to the uploaded file, which I need.
If anyone has any idea how to get this to work, it would be really appreciated!
From what I can tell here... you’re using API calls to operate a bot. In reality, this is a very complex process which is why we have libraries such as discord.py to make everything simpler. If you’re looking to create a bot, you should totally check out their documentation.

Ask for how to get user profile after callback

My web application is using Single Sign On (SSO) service from IBM Bluemix. This is the credentials info of my SSO service:
{
"SingleSignOn": [
{
"credentials": {
"secret": "MYSECRET",
"tokenEndpointUrl": "https://adminwebsso-jjjfvxi6wy-cq17.iam.ibmcloud.com/idaas/oidc/endpoint/default/token",
"authorizationEndpointUrl": "https://adminwebsso-jjjfvxi6wy-cq17.iam.ibmcloud.com/idaas/oidc/endpoint/default/authorize",
"issuerIdentifier": "adminwebsso-jjjfvxi6wy-cq17.iam.ibmcloud.com",
"clientId": "MYCLIENTID",
"serverSupportedScope": [
"openid"
]
},
"syslog_drain_url": null,
"volume_mounts": [],
"label": "SingleSignOn",
"provider": null,
"plan": "professional",
"name": "VA-Admin-Console-R1-SSO",
"tags": [
"security",
"ibm_created",
"ibm_dedicated_public"
]
}
]
}
From my Application, I redirect to Login page of IBM like URL:
https://adminwebsso-jjjfvxi6wy-cq17.iam.ibmcloud.com/idaas/oidc/endpoint/default/authorize?response_type=code&client_id=MYCLIENTID&redirect_uri=http://localhost/callback≻ope=openid%20openid
After login success IBM redirect to my web application, I can get parameter "code" from callback URL (http://localhost/callback?scope=openid&code=bngM6aV5cYHAvhv7wLAM5QSWFDARn7).
From there, I use the "code" to to get user profile. I have try to use AJAX to get user profile:
var settings = {
"async": true,
"crossDomain": true,
"url": "https://idaas.ng.bluemix.net/sps/oauth20sp/oauth20/token",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded",
"authorization": "Basic RXhhbXBsZV9BcHBJRDpWUFlndEdXRlRvYVpZSUNTRzhJeVZFV000bUZicGpsU2t4RlRRbzlySkRGZDdzckc=",
"cache-control": "no-cache"
},
"data": {
"client_secret": "MYSECRET",
"grant_type": "authorization_code",
"redirect_uri": "http://localhost/callback",
"code": "bngM6aV5cYHAvhv7wLAM5QSWFDARn7",
"client_id": "MYCLIENTID"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
From ajax post above, I have tried to use the "code" from callback, but I've got an error message:
500 Error: Failed to establish a backside connection
I've got stuck here and don't know how to get user profile from SSO.
With in the SSO Service there are some inbuilt macros that can be used to get the user name, for more information please see.
https://console.bluemix.net/docs/services/SingleSignOn/customizing_pages.html#customizing_pages
#USERNAME# The user ID of the authenticated user.

Post data on Kinvey DataStore with Business Logic

I just started to work with Kinvey and I'm having some issues to POST data via REST api.
If I go in the datastore I'm able to save it, but it doesn't work when sending via POST.
To post data, I'm using the URL "/appdata/APP_KEY/DATASTORE/" and sending Authorization, X-Kinvey-API-Version and Content-Typein the Headers.
And I get back "An unknown internal error occured in the processing of the Business Logic code."
When I add my business logic with App Engine (for a while, it just returns status=200 to Kinvey), I have the same error:
{
"error": "BLInternalError",
"description": "The Business Logic script did not complete. See debug message for details.",
"debug": "An unknown internal error occured in the processing of the Business Logic code."
}
Does anyone have any idea where am I doing wrong?
For the last, even when I call Kinvey via GET the method that Kinvey calls App Engine is POST, is there a way to change it?
Despite the errors, I always have the log of access in Google App Engine.
Thank you!
I sent an email to Kinvey support and they helped me a lot.
Some of my mistakes:
The JSON that I was returning back was wrong [*];
I didn't add in the header of my response the Content-Type and status.
Now it works perfectly!
[*] The JSON that I send back in the body of the response is:
{
"request": {
"method": "<redacted>",
"username": "<redacted>",
"entityId": "<redacted>",
"collectionName": "<redacted>",
"headers": {
"connection": "<redacted>",
"host": "<redacted>",
"x-forwarded-for": "<redacted>",
"x-forwarded-port": "<redacted>",
"x-kinvey-api-version": "<redacted>",
"x-real-ip": "<redacted>",
"authorization": "<redacted>",
"x-forwarded-proto": "<redacted>"
},
"body": "<redacted>",
"params": "<redacted>"
},
"response": {
"complete": True,
"headers": {
"x-powered-by": "<redacted>",
"x-kinvey-api-version": "<redacted>",
"x-kinvey-request-id": "<redacted>"
},
"body": {},
"error": None,
"statusCode": 200
}
}
Thanks again to Brian in the Kinvey support!
[]'s

Resources