Hail API AccessToken method - api

I'm trying to get access token from hail after get an authorization code from url https://hail.to/oauth/authorise?client_id={$client_id}&redirect_uri={$redirect_url}&response_type=code&scope=user.basic+user.manage+org.basic+content.read+content.read+content.connections
After getting the code from the above url, the documentation they provide does not state what should be the correct parameter to get an access_token. The documentation says it should be a POST method to get access token by using url https://hail.to/api/v1/oauth/access_token?client_id={$client_id}&client_secret={$client_secret}&grant_type=authorization_code&code={$client_access_token_code}&redirect_uri={$redirect_url}.
When I try this, I get the following error response:
{
"error" : {
"message" : "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \"grant_type\" parameter.",
"error_code" : null
}
}
If anyone has faced this problem, please help me out on this.
I don't know what should be the correct parameter for grant type.

Related

What is result.queryResult.fulfillmentMessages[0].text.text[0] in react-native-dialogflow?

When I followed this tutorial:
https://blog.jscrambler.com/build-a-chatbot-with-dialogflow-and-react-native/
I'm having an error within the handleGoogleResponse() method as result.queryResult is undefined. If I send a message as a user, there is no response collected from Dialogflow and presented back to the user.
What does this line of code mean in the handleGoogleResponse() method?
let text = result.queryResult.fulfillmentMessages[0].text.text[0];
What is result.queryResult? What do I do since result.queryResult is undefined?
I noticed that once I open the chatbot screen my console shows:
"generating jwt for "Object {\n "email": "integrate-dialogflow#mt-bot-wkgm.iam.gserviceaccount.com",\n "key": ....."
with the key information for my service account. This means it is able to read my env.js file?
Edit:
console.log(result) returns [object Object]
console.log(result.responseID) returns undefined
console.log(result.queryResult) returns undefined
console.log(result.webhookStatus) returns undefined
console.log(result.outputAudio) returns undefined
console.log(result.outputAudioConfig) returns undefined
console.log(JSON.stringify(result)) returns
{"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"}}
If you don't pass authorization you don't get queryResult since an exception is raised before.
I think it is clear that you have an auth problem.
Could you show your env.js (withe modified key, etc...) and the code of dialogflow lib configuration ?

Question about testIamPermissions method in Billing API

I'm trying to use cloudbilling.billingAccounts.testIamPermissions in the APIs Explorer, but I get an error.
API URL
https://developers.google.com/apis-explorer/?hl=ko#p/cloudbilling/v1/cloudbilling.billingAccounts.testIamPermissions?resource=billingAccounts%252F01183E-6A3E97-BE2C7A&resource=%257B%250A%257D&_h=1&
Error Result
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
The error message appears as 'Request contains an invalid argument', so the value entered in resource seems to be incorrect.
I entered billingAccounts / {billingAccountID} for resource, but I do not know why I get an error.
{billingAccountID} has entered the billing account ID you are using.
What value should be put in the resource?
You need to use your full ID "billingAccounts/012345-567890-ABCDEF`" as an string. Also avoid to share your private information for security reasons use examples instead.
Confirm that the other options of the API works for you.

Laravel 5.7 Handle email verification errors from API

I'm using laravel 5.7 to build an API REST.
When I add the verified middleware to my route group and I try to login with an unverified user by my client api, I get the error 400 Bad request. This error is too generic and don't show the problem clearly for my customer (it's happens in a login form).
If I to edit the render() method in Handler.php to ignore the isApiCall() and return parent::render($request, $e);, so I get the full error (Your email address is not verified, status 403), but when I try to return this in a json object with response()->json([$e]), the response is always empty.
So how to handle properly the api errors to be return the full message from exception, in this case?
You probably have already solved this problem, but this solution might help someone else:
The reason why your response was returning an empty array is because you were passing an Exception type object into the json function that is expecting an array. The response should look like this:
return response()->json(['message' => $e->getMessage()]);
This will return a json response like:
{
"message": "Your email address is not verified"
}

Need To Resolve Yelp API Response Error: “Signature is invalid”

My issue is when I try and fetch the Yelp API I keep getting this error time after time and i'm not sure why i've checked all the parameters and still cant get anything back from Yelp
My Yelp API Fetch Link -
https://api.yelp.com/v2/search?term=food&ll=37.788022,-122.399797&oauth_consumer_key=MY_Consumer_Key&oauth_token=MY_TOKEN&oauth_signature_method=HMAC-SHA1&oauth_signature=TOKEN_SECRET&oauth_timestamp=1456337018&oauth_nonce=1456337018
My Error -
error: {
text: "Signature was invalid",
id: "INVALID_SIGNATURE",
description: "Invalid signature. Expected signature base string:
GET&https%3A%2F%2Fapi.yelp.com%2Fv2%2Fsearch&ll%3D37.788022%252C-122.399797%26oauth_consumer_key%3DG02O6tXnFkSbsGYOJxCQDw%26oauth_nonce%3D1456337018%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1456337018%26oauth_token%3DBPMpqKrD4dA4xGGHKtC_-xitzb5LRNn8%26term%3Dfood"
}
Error in your API call url,yelp using oauth 1.0a,Which one url parameters should be in alphabet order(this one is telling clearly in your error description), So API call url should be like this:
https://api.yelp.com/v2/search?ll=37.788022,-122.399797&oauth_consumer_key=MY_Consumer_Key&oauth_nonce=1456337018&oauth_signature=TOKEN_SECRET&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1456337018&oauth_token=MY_TOKEN&term=food

Can't get Token based authentication working with NancyFX

I am trying Token based authentication with NancyFX. Token is getting generated perfectly but when I am passing header in Get Request, I can't get pass this.RequiresAuthentication() and getting unauthorized error.
Here is my token format
Token:{ token: "ZGVtb1VzZXINCmFkbWlufG5vbmFkbWluDQo2MzU1MDU5NjU4NzExNTE5MzkNCk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDYuMzsgV09XNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8zOC4wLjIxMjUuMTExIFNhZmFyaS81MzcuMzY=:QerS8B701zoC1xqlvSxuz0EbrBDtfgEzkDWzlEj9ChA=" }
Am I passing wrong way?
I have also tried
Token:{ ZGVtb1VzZXINCmFkbWlufG5vbmFkbWluDQo2MzU1MDU5NjU4NzExNTE5MzkNCk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDYuMzsgV09XNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8zOC4wLjIxMjUuMTExIFNhZmFyaS81MzcuMzY=:QerS8B701zoC1xqlvSxuz0EbrBDtfgEzkDWzlEj9ChA=}
and also
"Token:{ ZGVtb1VzZXINCmFkbWlufG5vbmFkbWluDQo2MzU1MDU5NjU4NzExNTE5MzkNCk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDYuMzsgV09XNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8zOC4wLjIxMjUuMTExIFNhZmFyaS81MzcuMzY=:QerS8B701zoC1xqlvSxuz0EbrBDtfgEzkDWzlEj9ChA=}"
But nothing work.
Please let me know if any more details are required.
The value of the authorization header must simply read "Token ZGVtb1VzZXINCmFkbWlufG5vbmFkbWluDQo2MzU1MDU5NjU4NzExNTE5MzkNCk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDYuMzsgV09XNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8zOC4wLjIxMjUuMTExIFNhZmFyaS81MzcuMzY" (no quotes).
The brackets in the documentation threw me off as well.