Oauth2, getting Forbidden error (youtube analytics) - oauth2-playground

1.- I have created an app
2.- Through Oauth2 I got the token for an user
3.- I try to get the Youbute Analytics for the user's channel that authorized my app. But I have the error 403 (Forbidden). I do not have any clue ... can you help me?
Regards, P.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Forbidden",
"reason" : "forbidden"
} ],
"message" : "Forbidden"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)

Related

A failure occurred while executing com.github.triplet.gradle.play.tasks.CommitEdit$Committer

trying to publish bundle but i got this error every time
> Task :app:publishRelease
Task :commitEditForComDotDigcoderDotTecsiDotHse FAILED
Committing changes
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':commitEditForComDotDigcoderDotTecsiDotHse'.
A failure occurred while executing com.github.triplet.gradle.play.tasks.CommitEdit$Committer
400 Bad Request
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.digcoder.tecsi.hse/edits/14074052962661642881:commit
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Only releases with status draft may be created on draft app.",
"reason" : "badRequest"
} ],
"message" : "Only releases with status draft may be created on draft app.",
"status" : "INVALID_ARGUMENT"
}

Atlassian Swagger Request Validator - Spring MVC Issue

I am using atlassian swagger request validator in my springboot application. I tried to configure all the beans as explained in the [official documentation][1]
[1]: https://bitbucket.org/atlassian/swagger-request-validator/src/master/swagger-request-validator-springmvc/. But I am getting the below error
{
"status": 400,
"error": "Bad Request",
"message": "{\r\n \"messages\" : [ {\r\n \"key\" : \"validation.request.body.schema.unknownError\",\r\n \"level\" : \"ERROR\",\r\n \"message\" : \"An error occurred during schema validation - null.\",\r\n \"context\" : {\r\n \"requestPath\" : \"/mybook/mypage/12345/rules/\",\r\n \"apiRequestContentType\" : \"application/json\",\r\n \"location\" : \"REQUEST\",\r\n \"requestMethod\" : \"POST\"\r\n }\r\n } ]\r\n}",
"trace": "com.atlassian.oai.validator.springmvc.InvalidRequestException: {\r\n \"messages\" : [ {\r\n \"key\" : \"validation.request.body.schema.unknownError\",\r\n \"level\" : \"ERROR\",\r\n \"message\" : \"An error occurred during schema validation - null.\",\r\n \"context\" : {\r\n \"requestPath\" : \"/mybook/mypage/12345/rules/\",\r\n \"apiRequestContentType\" : \"application/json\",\r\n \"location\" : \"REQUEST\",\r\n \"requestMethod\" : \"POST\"\r\n }\r\n } ]\r\n}\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.createValidationException(DefaultValidationReportHandler.java:96)\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.processApiValidationReport(DefaultValidationReportHandler.java:63)\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.handleRequestReport(DefaultValidationReportHandler.java:49)\r\n\tat com.atlassian.oai.validator.springmvc.OpenApiValidationInterceptor.preHandle(OpenApiValidationInterceptor.java:96)\r\n\tat org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:136)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1033)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:660)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)\r\n\tat
Any pointers to resolve this issue will be helpful
I believe the issue is with the latest version. I used 2.7x and is working fine

How I can get authentication token or do loging in Elastic Search using REST API? For example from POSTMAN

I'm trying to list data from Elastic Search using the REST API on Postman.
But I get a security_exception error
I read the elastic documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html
but didn't work.
I'm using Elastic 7.2
Method: POST
Content-type: Application/json
URI: http://xxx.xxx.xxx.xxx:9200/_security/oauth2/token
BODY:
{
"grant_type" : "password",
"username" : "user_name",
"password" : "correct_password"
}
I need this service to return the authentication token. But this is the response:
{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "missing authentication credentials for REST request [/_security/oauth2/token]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type": "security_exception",
"reason": "missing authentication credentials for REST request [/_security/oauth2/token]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status": 401
}
Try to do a basic authentication instead. And pass in the body just the grant_type.

QuickBooksOnline API - Customer Balance API error - Permission Denied when other non reports API working

QuickBooksOnline API - Customer Balance is not working when other non reports API working with same access token
Request
https://sandbox-quickbooks.api.intuit.com/v3/company/123146076363264/reports/CustomerBalance?customer=1
Response
{
"Fault": {
"Error": [
{
"Message": "Permission Denied Error",
"Detail": "Permission Denied Error : You do not have the access rights to use this feature.",
"code": "5020",
"element": "ReportName"
}
],
"type": "ValidationFault"
},
"time": "2019-06-05T05:30:57.879-07:00"
}

Generic custom error response in Dingo API

I am trying to abstract all my error responses to match my API documentation for developing a good, pragmatic API using Lumen and the Dingo API package:
A JSON error body should provide a few things for the developer - a useful error message, a unique error code (that can be looked up for more details in the docs) and possibly a detailed description. JSON output representation for something like this would look like:
{
"code" : 1234,
"message" : "Something bad happened :(",
"description" : "More details about the error here"
}
At the moment, the Dingo API only provides me with the following response:
{
"message": "Could not create new user.",
"status_code": 422
}
1. How can I add extra fields to all error responses, e.g "description" and "code"
The configuration page shows a possible error format to set on your bootstrap/app.php file but I'm wondering how I can add possible new tags and use these.
I know it's possible using a custom exception and returning a new response:
app('Dingo\Api\Exception\Handler')->register(function (\App\Exceptions\ValidationException $exception) {
return Response::make(['code' => $exception->getCode(), 'message' => $exception->getMessage()], 401);
});
I want to know if this is the best practice to do it like this but on all exceptions (including the default ones of Dingo/Symfony), for example using the configuration parameters: ->setErrorFormat([]);
2. Change validation errors format
Validation errors for PUT, PATCH and POST requests will need a field breakdown. This is best modeled by using a fixed top-level error code for validation failures and providing the detailed errors in an additional errors field, like so:
{
"code" : 1024,
"message" : "Validation Failed",
"errors" : [
{
"code" : 5432,
"field" : "first_name",
"message" : "First name cannot have fancy characters"
},
{
"code" : 5622,
"field" : "password",
"message" : "Password cannot be blank"
}
]
}
Currently, Dingo API provides me the JSON in the following format:
{
"message": "Could not create new user.",
"status_code": 422,
"errors": {
"username": [
"The username field is required."
],
"password": [
"The password field is required."
]
}
}