Hi I was wondering if someone could help me ,I am trying to use twilios' rest api and im running into some trouble. MyAccountIdSid,mySid and phone numbers are filled in in the actual request,Is there something i am doing wrong,
I get Your "AccountSid or AuthToken was incorrect" .
Can someone show me the correct way to make this request for sending an sms please.
I am trying to send a text message
Post Request Url i am using :
https://api.twilio.com/2010-04-01/Accounts/MyAccountIdSid/Messages.json
{
"account_sid": "MyAccountIdSid",
"api_version": "2010-04-01",
"body": "HelloWorld",
"num_segments": "1",
"num_media": "1",
"date_created": "Wed, 18 Aug 2010 20:01:40 +0000",
"date_sent": null,
"date_updated": "Wed, 18 Aug 2010 20:01:40 +0000",
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": "+353xxxxxxxx",
"price": null,
"sid": "mySID",
"status": "queued",
"to": "+353xxxxxxxxx",
"uri": "/2010-04-01/Accounts/MyAccountIdSid/Messages/mySid.json"
}
Twilio developer evangelist here.
If you're copying it from here, be aware that the first part of it is the request, and the second is the response, so what you're trying to send to Twilio is the response, hence why it's not working for you.
What you need to send to Twilio is the following:
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
-d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
-d "To=%2B15558675309" \
-d "From=%2B14158141829" \
-d "MediaUrl=http://www.example.com/hearts.png" \
-u 'AC36b9a6be2f98274fe61d15b63aabf1e0:{AuthToken}'
I've created a quick screeencast showing you how to do that with postman 2. Hope it helps you.
Note : Enhancement of Marcos Placona's Answer
In the Authorization section, set 'AUTH TOKEN' in 'password' field.
You can find 'AUTH TOKEN' just below Account Summary.
https://www.twilio.com/console
https://www.twilio.com/docs/api/errors/20003
'Authenticate using your Account SID as the username, and your Auth Token as the password.'
Related
I'm getting the following error when attempting to create an Order in a Live Application:
{
"issue": "PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING",
"description": "Payee account is not setup to be able to process card payments. Please contact PayPal customer support."
}
I did not get this error when building out the API in the Sandbox environment, I've tried to contact support multiple times, at this time I've spoken to over 5 different support representatives and bounced around between various departments but no one seems to be able to point me in the right direction as to how I can address this account restriction.
I'm sending in the following request:
curl -v -X POST https://api-m.paypal.com/v2/checkout/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-H "PayPal-Request-Id: ######" \
-d '{
"intent": "AUTHORIZE",
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"payment_source": {
"card": {
"number": "4111111111111111",
"expiry": "2023-02",
"billing_address": {
"postal_code": "95131",
"country_code": "US"
}
},
"stored_credential": {
"payment_initiator": "MERCHANT",
"payment_type": "ONE-TIME",
"usage": "DERIVED"
}
}
}'
The expectation is that users can enter in their card details through a Phone IVR that data gets passed off to Paypal in the form of an order for a transaction to processed. I tested the workflow in the Sandbox and it worked just fine, but for some reason it just does not work in the Live App.
The integrate card payments documentation has a note that says:
Before you go live, you need to complete production onboarding to be eligible to process cards with your live PayPal account.
I'm trying to get the teams for the logged in user for some token. With a personal access token, everything looks ok:
# properly returns a bunch of teams
curl -H "Authorization: token ghp_123abc" 'https://api.github.com/user/teams'
[
{
"name": "abc",
"id": 123,
"node_id": "abc=",
"slug": "123",
...
]
but when using an OAuth bearer token from an OAuth app, I get an empty [] from the API:
$ curl -H "Authorization: bearer gho_123abc" 'https://api.github.com/user/teams'
[
]
I know both tokens are valid since the response for https://api.github.com/user is the same regardless of token, but I just have no idea why the response would be different based on token (both have proper permissions to read:org as confirmed in the response headers)
I am working with Prime Trust's API and I'm unable to create a JWT token. I am following the documentation which states the following:
Getting Started with the Custody APIs - (Sandbox Specific)
You need totake the current steps to get started via the APIs
Create a new User
Authenticate with the APIs by getting a JWT.
Create an Account.
Test Mode APIs - Approve the owner of the account for CIP and AML.
Test Mode APIs - Open an Account for Funds
I was able to create a user following the documentation, but I'm stuck on the creation of the JWT Token. According to the documentation I should create the token using the below:
JSON Web Tokens (JWTs)
JSON Web Tokens or JWTs are the preferred method of authentication for all requests besides actually generating a JWT. Since JWTs are not persisted server resources, they are not created using a JSONAPI style request or response.
Creating a new JWT
A new JWT can be created by passing a user's credentials using HTTP
Basic Authorization to the following endpoint. Any special settings on
the JWT such as IP whitelisting, expiration time or TOTP MFA must be
passed in as form values during creation.
POST /auth/jwts
Here's the example call they give:
curl --location --request POST "https://sandbox.primetrust.com/auth/jwts" \
--header "Content-Type: application/x-www-form-urlencoded" \
--form "expires_at=2019-06-06T07:30:40Z" \
--form "otp=382948" \
--form "cidr[]=192.168.1.213/32" \
--form "cidr[]=127.0.0.1/32"
I've tried a combination of different calls with the details outlined below, but have the below error on all of my attempts:
401 Unauthorized
{
"errors": [
{
"status": 401,
"title": "Not authenticated."
}
]
}
Bodies
POST https://sandbox.primetrust.com/auth/jwts
POST https://sandbox.primetrust.com/auth/jwts
{
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"data": {
"email": "email#email.com",
"password": "123abc"
}
}
POST https://sandbox.primetrust.com/auth/jwts
{
"name": "name",
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"id": {guid},
"name": "name",
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"id": {guid},
"password": "123abc"
}
Headers
Content-Type: application/json
expires_at: 2019-12-31T11:59:59Z
alg: HS256
typ: JWT
I recognize that my calls don't line up with the example call exactly, but my understanding from the documentation is that all that should be required is a name & password to generate the JWT token. What am I missing?
Update 1
Based on reaching out to Prime Trust support the username/email need to be included as parameters rather than in the body of the url. I tried the below URLs without success
https://sandbox.primetrust.com/auth/jwts?email=email#email.com&password=123abc&id={guid}
https://sandbox.primetrust.com/auth/jwts?email=email#email.com&password=123abc
https://sandbox.primetrust.com/auth/jwts?password=123abc&id={guid}
https://sandbox.primetrust.com/auth/jwts?name=name&password=123abc
According to docs:
Creating a new JWT
A new JWT can be created by passing a user's credentials using HTTP Basic Authorization to the following endpoint. Any special settings on the JWT such as IP whitelisting, expiration time or TOTP MFA must be passed in as form values during creation.
So basically all you need is create an Authorization header set to Basic Auth with your credentials:
curl -X POST \
https://sandbox.primetrust.com/auth/jwts \
-H 'Authorization: Basic YOUR_BASE64_ENCODED_EMAIL_AND_PASSWORD' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache'
I've already configured adMob for my Android apps and have no problem with that.
Right now I'm looking for any way to check my apps earnings (if possible for each of the apps separately) in any given moment.
Somebody knows if there's any API, library or Web Service I can use to access my AdMob account and get info about my apps' statistics and so on ?
I've already checked the official APK but it seems only intended to show the ads in your app and nothing else.
Thanks in advance
I answer myself.
I was doing some research, and I found that after the recent changes on AdMob, and the migration to AdSense, you must use the AdSense API to get this info.
In particular, each Android app is associated with a "adunit" id, so if you want to check the info of any particular app you might use:
https://developers.google.com/adsense/management/v1.4/reference/accounts/reports/generate
with the following data:
accountId = your Publisher ID (pub-XXXXXXX)
startDate and endDate = The interval of dates you want to check
dimension = AD_UNIT_ID
metric = EARNINGS
With this query you'll have the required info, separated by App.
You get the results in JSON form.
There is an AdMob API available to get the AdMob specific data.
It provides a possibility to generate network and mediation reports available. It could be as simple as:
curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/mediationReport:generate \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
--data #- << EOF
{
"report_spec": {
"date_range": {
"start_date": {"year": 2020, "month": 4, "day": 1},
"end_date": {"year": 2020, "month": 4, "day": 1}
},
"dimensions": ["AD_SOURCE", "AD_UNIT", "PLATFORM"],
"metrics": ["ESTIMATED_EARNINGS"]
}
}
EOF
.net: https://developers.google.com/api-client-library/dotnet/apis/admob/v1
java: https://github.com/googleapis/google-api-java-client-services/tree/master/clients/google-api-services-admob/v1
Get an Oauth2.0 access token
With oauth2l
install: https://github.com/google/oauth2l
oauth2l header --json <path_to_secret_json> https://www.googleapis.com/auth/admob.report
path_to_secret_json - is one from the credentials page on the google cloud console.
With curl
Replace the oauth2_client_id with the one you have in your “Cloud project credentials - OAuth 2.0 client IDs” page. (https://console.developers.google.com/apis/credentials?project=)
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadmob.report&response_type=code&client_id=&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
Open this link in incognito browser mode;
Follow the instruction, and accept the consonant screen with AdMob publisher's account;
Copy the code, it would be needed for the following request:
curl -L \
-d "client_id=<oauth2_client_id>" \
-d "client_secret=<oauth2_secret>" \
-d "grant_type=authorization_code" \
-d "code=<sign_in_code_from_the_previous_step>" \
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
https://accounts.google.com/o/oauth2/token
oaut2_client_id and oauth2_secret can be found on the OAuth 2.0 client Id page.
Response:
{
"access_token": "<access_token>",
"expires_in": 3600,
"refresh_token": "<refresh_token>",
"scope": "https://www.googleapis.com/auth/admob.report",
"token_type": "Bearer"
}
Using "LIVE" credentials, I'm getting an INTERNAL_SERVICE_ERROR accepting a credit card payment, using this resource: https://api.paypal.com/v1/payments/payment. Same error happens on the web and via cURL. NOTE: This does not happen in SANDBOX only LIVE. See steps to recreate below. For this post, I had to add a space in "http s" as I cannot submit more than 2 links.
Get an OAuth token (substitute username/password in LIVE_USER_ID:LIVE_PASSWORD
curl http s://api.paypal.com/v1/oauth2/token -H "Accept: application/json" -H "Accept-Language: en_US" -u "LIVE_USER_ID:LIVE_PASSWORD" -d "grant_type=client_credentials"
No problem getting a token using LIVE credentials. Add the token to the following request to the resource:
curl -v http s://api.paypal.com/v1/payments/payment \
-H "Content-Type:application/json" \
-H "Authorization:Bearer YK.GUHkGhBAQgGgGkilvHoL7DdE9SVq.IDl-mRwAZeM" \
-d '{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "5500005555555559",
"type": "mastercard",
"expire_month": 12,
"expire_year": 2018,
"cvv2": 111,
"first_name": "Joe",
"last_name": "Shopper"
}
}
]
},
"transactions": [
{
"amount": {
"total": "0.01",
"currency": "USD"
},
"description": "This is the payment transaction description."
}
]
}'
"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"http_s://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"525bfb7a6382a"}johnruffin:~ johnruffin$
Thoughts???
Thanks for bringing this issue to our attention. I've opened an internal bug with the payments rest api development team. From the debug id provided I see that the credit card is being refused. In the future the error message from this scenario will fall under this error condition: https://developer.paypal.com/webapps/developer/docs/api/#CREDIT_CARD_REFUSED
Please try a another/valid credit card to verify.
Looks like the URL is not well formed. It's https and not http s as provided above.
Tried the calls now, it works fine. Please check and confirm.