Loopback: 401 Authorization Required after successful login - node.js

I am currently facing an issue where I always get a 401:
For example when I try to do a GET request to /users/{id}/customer I am getting the following response:
{
"error": {
"statusCode": 401,
"name": "Error",
"message": "Authorization Required",
"code": "AUTHORIZATION_REQUIRED",
"stack": "Error: Authorization Required\n at /var/www/p-web-2-api-node/node_modules/loopback/lib/application.js:430:21\n at /var/www/p-web-2-api-node/node_modules/loopback/lib/model.js:358:7\n at /var/www/p-web-2-api-node/node_modules/loopback/common/models/acl.js:529:16\n at /var/www/p-web-2-api-node/node_modules/async/dist/async.js:3874:9\n at /var/www/p-web-2-api-node/node_modules/async/dist/async.js:473:16\n at iteratorCallback (/var/www/p-web-2-api-node/node_modules/async/dist/async.js:1050:13)\n at /var/www/p-web-2-api-node/node_modules/async/dist/async.js:958:16\n at /var/www/p-web-2-api-node/node_modules/async/dist/async.js:3871:13\n at /var/www/p-web-2-api-node/node_modules/loopback/common/models/acl.js:511:17\n at /var/www/p-web-2-api-node/node_modules/loopback/common/models/role.js:442:21\n at process._tickCallback (internal/process/next_tick.js:176:11)"
}
}
I have acquired the correct token through login, I have set the token in the /explorer (which is added as a query parameter) but the 401 always shows up.
When I disable the server.enableAuth(); in /boot/authentication.js it works. I have tried acl's and have either removed everything or granted $everyone full access.

Related

Youtube.analytics.query api giving forbidden error

I want to fetch the analytics of any channel of youtube that basically are not owned by me. I am using this API.
If this is not the right API please suggest me how to achieve this.
Also, I am using node.
https://youtubeanalytics.googleapis.com/v2/reports?dimensions=day&endDate=2019-01-01&ids=channel%3D%3DUCZSNzBgFub_WWil6TOTYwAg&metrics=likes&startDate=2018-01-01
Response:
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
You need to understand the difference between private and public data. Public data is data that can be accessed by anyone. Public videos on YouTube for example
Private data is data that is owned by a user. A good example of that would be the analytics for a channel on Youtube. You cant access this kind of information without the permission of the user who owns it.
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Means that the currently authenticated user doesn't have permission to do what you are trying to do. You need to login with a user who has access to this data. I suggest you ask the owner of the channel to give you access.

Facebook API error 2069006 "User Cannot See This App"

I have a page on Facebook and app to do some actions on it.
I can get reviews of my page using this API:
GET 2044933538893604/ratings
And I can get comments of some review.
GET 2009974472404526/comments
I have problem when I try to add comment to that review post.
POST 2009974472404526/comments
{
"message" : "some message"
}
I am getting following error:
{
"error": {
"message": "Permissions error",
"type": "OAuthException",
"code": 200,
"error_subcode": `2069006`,
"is_transient": false,
"error_user_title": "User Cannot See This App",
"error_user_msg": "The user who owns object 2,009,974,472,404,526 cannot see this app.",
"fbtrace_id": "CIrr69/JFp/"
}
}
I have a token that has all permissions enabled.
I see someone had the same problem here Got a Facebook error as "Code 200, subcode 2069006" while replying reviews by a page access token at my Facebook page and looks like he had found a solution but for some reason it is not posted there.

Expected OAuth 2 access token while importing VAPID Push subscriptions into Firebase

I am trying to import vapid push subscriptions into firebase. I found some solution in https://developers.google.com/instance-id/reference/server#import_push_subscriptions. It thew following error. Please help me regarding this.
POST : https://iid.googleapis.com/v1/web/iid
Headers :
Content-Type:application/json
Authorization:key=MY_SERVER_KEY
BODY:
{
"endpoint" : "https://fcm.googleapis.com/fcm/send/my_sub_key",
"keys" : {
"p256dh" : "hidden_key",
"auth" : "hidden_auth"
}
}
}
Response:
"error": { "code": 401, "message": "Request is missing required authentication credential. 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" }

Create a new customer in the sandbox receive a 500 error. Google Reseller API v1

I have authenticated my request and when I'm trying to create a new customer in the sandbox, i receive a 500 error.
Request:
POST https://www.googleapis.com/apps/reseller/v1sandbox/customers
{
"customerDomain": "test.com",
"kind": "reseller#customer"
}
Response:
500 Internal Server Error
- Show headers -
{
"error": {
"code": 500,
"message": null
}
}
search the word "required" in this page
https://developers.google.com/admin-sdk/reseller/v1/reference/customers#resource

PATCH /subscriptions/{sid} returning "InternalServerError"

In the Azure API Management REST API Subscription entity,
when I call
PATCH /subscriptions/xxxxxxxxxxxxxxxx?api-version=2014-02-14-preview
with a request body containing primaryKey=yyyyyyyyyyy, it returns an unexpected 500 Internal Server Error with body:
{
"error": {
"code": "InternalServerError",
"message": "Request processing failed due to internal error.",
"details": null
}
}
Am I doing something wrong?
Documentation: http://msdn.microsoft.com/en-us/library/azure/dn776325.aspx#UpdateSubscription

Resources