I struggle in call the REST API at Dotmailer.
he provide a document for call the OAuth and get the token.
but it's always throws the same error.
Input is
Post Method
URI: https://r1-app.dotmailer.com/OAuth2/Tokens.ashx
JSON input is
{
"client_id" : "apiuser-XXXXXXXXXXX#apiconnector.com",
"redirect_uri" : null,
"client_secret" : "XXXXXXXXXXXX",
"grant_type": "authorization_code",
"code":"MyServerCode",
"test_mode":true
}
Out put is
{
"error": "invalid_request",
"error_description": "There was a problem with the 'grant_type' parameter: The parameter is required."
}
Anyone know the error.
Thanks in advance...
I think Dotmailer OAuth have some problem.
I was used alternatively Basic Authentication method to access the dotmailer API.
Base URI = https://api.dotmailer.com/v2/
Header
Content-type: application/json
Authorization: Basic base64_convertion(username:password).
Sample
Content-type: application/json
Authorization: Basic XXXXXXXXXXXXXXXX.
Use WADL method.
https://api.dotmailer.com/v2/help/wadl
Related
Good Morning,
I'm trying to get shareid of my test publication on Api Linkedin my request is:
https://api.linkedin.com/v2/rest/posts/shareUrn(urn:li:share:6947445733109194752)?X-Restli-Protocol-Version=2.0.0&LinkedIn-Version=202206
I also have my token but I donĀ“t understand the reply:
{
"serviceErrorCode": 0,
"message": "Resource rest does not exist",
"status": 404
}
Any help is greatly appreciated
Thanks
you either go with 'V2' versioning or 'rest' versioning. The endpoints with headers should be (in python):
V2:
url = 'https://api.linkedin.com/v2/rest/posts/shareUrn/'
headers = {
'Authorization': f'Bearer {token}',
}
Rest:
url = 'https://api.linkedin.com/v2/rest/posts/shareUrn/'
headers = {
'Authorization': f'Bearer {token}',
'LinkedIn-Version': REST_VERSION,
}
where REST_VERSION is something like '202212'.
Optionally (not all LI endpoints accept it) you can add to the headers info about protocol:
"X-Restli-Protocol-Version": "2.0.0"
Remove "/rest" from the endpoint.
Include "X-Restli-Protocol-Version" and "LinkedIn-Version" in the header of the request.
Make sure all the query params in the request are in correct format.
Goodluck!
I want to get data from a firestore via the REST API. I'm using an HTTP-Client (Webstorm) and do the following.
First I authenticate with Google which works fine and does return a token:
POST https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=<firebase-api-key>
Accept: application/json
Content-Type: application/json
{
"email": "some#email.com",
"password": "notthispassword"
}
But then, trying to get data from the firestore (not realtime-db) like this
GET https://firestore.googleapis.com/v1/projects/<projectId>/databases/(default)/documents/<collection>
Accept: application/json
Authorization: Bearer <token from auth response>
it keeps telling me:
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
These are my firestore security rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
I would be happy if somebody could tell me where I am going wrong here.
The first part of the solution was to read the response carefully. It containes the following link https://developers.google.com/identity/sign-in/web/devconsole-project.
Then I had to understand that if you are using the google-identitiy-toolkit you kind of left the firebase-realm and must append the api-key generated in the GC-console (not the firebase-key!) (https://console.cloud.google.com/apis/credentials) to the URL used to fetch the data like this:
GET https://firestore.googleapis.com/v1/projects/<projectId>/databases/(default)/documents/<collection>?key=<google-cloud-api-key>
Accept: application/json
Authorization: Bearer <token from auth response>
I'm trying to set up an axios post request to add members to an audience list, but I can't figure out how to add the API key (keeps giving error 401: 'Your request did not include an API key.'). I've tried a bunch of things in the "Authorization" header, like what I put below (also: "Bearer ${mailchimpKey}", "${mailchimpKey}", "Bearer ${mailchimpKey}", "Basic ${mailchimpKey}", and probably more...).
I also don't know what the "username" would be, but "any" worked when I tested the API elsewhere.
Does anyone know how I should set this up?
axios
.post(
`https://${server}.api.mailchimp.com/3.0/lists/${list_id}/members`,
{
email_address: email,
status: "subscribed",
},
{
"User-Agent": "Request-Promise",
Connection: "keep-alive",
Authorization: `Basic any:${mailchimpKey}`,
// Testing on localhost
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type",
}
)
If your intention is to use HTTP Basic authentication, just use the Axios auth config option
axios.post(
`https://${server}.api.mailchimp.com/3.0/lists/${encodeURIComponent(list_id)}/members`,
{
email_address: email,
status: "subscribed",
},
{
auth: {
username: "anystring",
password: mailchimpKey
},
headers: { // personally, I wouldn't add any extra headers
"User-agent": "Request-Promise"
}
}
)
HTTP Basic auth headers look like
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
where the string after "Basic" is the Base64 encoded "username:password" string. Axios provides the auth option as a convenience so you don't need to encode the string yourself.
Some other problems you had were:
Adding request headers outside the headers config option
Attempting to send Access-Control-Allow-Origin and Access-Control-Allow-Headers as request headers. These are response headers only. Adding them to your request will most likely cause more CORS errors
Using this documentation I'm trying to test the request using Postman the example on the right side:
$ curl https://subscriptions.zoho.com/api/v1/organizations
-H 'Authorization: Zoho-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f'
-H 'X-com-zoho-subscriptions-organizationid: 10234695'
Maybe I'm not setting the parameters right but this is how it looks for the moment.
A new GET Request, in the url input: https://subscriptions.zoho.com/api/v1/organizations
And under that, in the Headers tab I added two key-value pairs:
Authorization: Zoho-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
Authorization: X-com-zoho-subscriptions-organizationid: 1023469
The returned result:
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
</body>
</html>
If I deleted the second key-value pair it returns this JSON:
{
"code": 57,
"message": "You are not authorized to perform this operation"
}
What is wrong with my approach?
Can you try this?
If you are sure of the api url, do validate the token and create a fresh token and
add it to header as below:
HeaderName : Authorization
HeaderValue: 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f
HeaderName : X-com-zoho-subscriptions-organizationid
HeaderValue: 10234695
I tried this and is getting,
{
"code": 14,
"message": "Invalid value passed for authtoken."
}
Might be the token got invalid.
Now I tried with a new token generated myself and I am getting now,
{
"code": 0,
"message": "success",
"organizations": [],
}
In short, you have to generate an auth token first and then hit the url with proper header value as shown above.
Thank you :)
I have followed and double checked the steps to get a bearer token from https://dev.twitter.com/oauth/application-only
i keep getting the following error :
Status : 403 Forbidden
{"errors":[{"code":99,"message":"Unable to verify your credentials","label":"authenticity_token_error"}]}
I tried passing grant_type=client_credentials in body as well as query parameter.
The URL i am hitting is : https://api.twitter.com/oauth2/token?grant_type=client_credentials
Headers Set :
Authorization : Basic [base64encoded(client_key:client_secret)]
Content-Type : application/x-www-form-urlencoded;charset=UTF-8
I am using poster as the rest client to make the calls.
Could any one point out where i may be going wrong.
Thanks a lot.
Send "grant_type=client_credentials" as the payload.
var options = {
"method":"post",
"headers": {
"Authorization":"Basic " + Utilities.base64Encode(param),
"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"
},
"payload" : "grant_type=client_credentials"
};
var response = UrlFetchApp.fetch(TOKEN_URL,options);