Can't delete account from Firebase - firebase

I am creating a simple app using NativeScript where administrators can add and delete users from a a Firebase database. I am being able to add the users easily, but I can't seem to figure out how to delete them. I am following the instructions found in the documentation: https://firebase.google.com/docs/reference/rest/auth#section-delete-account
but when I submit the post request like this:
.post(https://identitytoolkit.googleapis.com/v1/accounts:delete?key=${FIREBASE_API_KEY},{ "idToken": userId }) .... (the rest of the code)
I get the following error:
This is the error I am getting:
JS: ERROR {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null
JS: },
JS: "status": 400,
JS: "statusText": "Bad Request",
JS: "url": "https://identitytoolkit.googleapis.com/v1/accounts:delete?key=[MY_API]",
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for https://identitytoolkit.googleapis.com/v1/accounts:delete?key=[MY_API]: 400 Bad Request",
JS: "error": {
JS: "error": {
JS: "code": 400,
JS: "message": "INVALID_ID_TOKEN",
JS: "errors": [
JS: {
JS: "message": "INVALID_ID_TOKEN",
JS: "domain": "global",
JS: "reason": "invalid"
JS: }
JS: ]
JS: }
JS: }
JS: }
I have tried all sorts of things, I have checked questions here, and nothing. Another user mentioned that the user I am trying to delete needs to have signed in before I delete it, but that did not work either. If any of you has any ideas on how to proceed I would appreciate it!

idToken is not the same as the userId, so the first thing you need to do is "log in" (use the SDK) as the user to retrieve his token and then use that token to delete the account.
I was able to do this using the methods described in this doc.

Related

The forbidden error occurs, when I try to link an account to another user with an email

I have a user's refresh token with these scopes:
'https://www.googleapis.com/auth/analytics https://www.googleapis.com/auth/analytics.edit https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/analytics.manage.users’’
The user has a few accounts and a forbidden error occurs for XXXX2 account when I try to give access to an account to another user(you can see at the below code and account list json). I checked this account's effective permission field, I see that it is an empty array as you can see below as well.
In my opinion, this error reason is that this user does not have ‘manage_users’ permissions for this account(XXXX2), so this is an expected error, isn't it?
PS: I can link XXXX1 properly with the below code.
My code :
linkAccount = self.service.management().accountUserLinks().insert(
accountId=accountId,
body={
'permissions': {
'local': [
'EDIT',
'MANAGE_USERS'
]
},
'userRef': {
'email': email}}).execute()
User Account list :
{
"id": "XXXX1",
"kind": "analytics#account",
"selfLink": "https://www.googleapis.com/analytics/v3/management/accounts/XXXX1”,
"name": "XXXX1",
"permissions": {
"effective": [
"COLLABORATE",
"EDIT",
"MANAGE_USERS",
"READ_AND_ANALYZE"
]
},
"created": "2014-02-17T17:52:10.911Z",
"updated": "2019-06-04T16:06:12.717Z",
"childLink": {
"type": "analytics#webproperties",
"href": "https://www.googleapis.com/analytics/v3/management/accounts/XXXX1/webproperties"
}
},
{
"id": "XXXX2”,
"kind": "analytics#account",
"selfLink": "https://www.googleapis.com/analytics/v3/management/accounts/XXXX2”,
"name": "XXXX2",
"permissions": {
"effective": []
},
"created": "2015-07-02T19:11:16.307Z",
"updated": "2019-03-05T21:16:19.552Z",
"childLink": {
"type": "analytics#webproperties",
"href": "https://www.googleapis.com/analytics/v3/management/accounts/XXXX2/webproperties"
}
}
Error Code :
<HttpError 403 when requesting https://analytics.googleapis.com/analytics/v3/management/accounts/XXXXX/entityUserLinks?alt=json returned "User does not have permission to perform this operation.". Details: "User does not have permission to perform this operation."
I would check what access the currently authenticated user has to the account in question.
If the user you are authenticated with only has read access. To the Analytica account there not going to be able to give your application the ability to add another user.

step by step implementation of nativescript push notification in nativescript

can anyone give step by step guidence starting from creating a helloworld app then the remaining steps to do push notifications.
i have already gone through the below link and failed to achieve that
https://github.com/EddyVerbruggen/nativescript-plugin-firebase
i have some progress on it, refer below code.
http.request({
url: 'https://fcm.googleapis.com/fcm/send',
method: "POST",
headers: { 'Authorization': 'key=AIzaSyBri16HAa7g2REEy******YFnTDGIlM_1k', 'Content-Type': 'application/json' },
content: JSON.stringify({
"notification": {
"title": "testingtesting",
"text": "some text",
"sound": "default",
"click_action": "GENERAL",
"badge": "1",
"showWhenInForeground": true
},
"content_available": false,
"data": {
"foo": "bar"
},
"priority": "High",
'to': "AAAACcS8hG0:APA91bEonX87xRfBHvccNheOR2ppFHZKaFlGGm6PRF6eEEYZg5Gd7uU_OU0GRJ0MkiTrR2gSDGO7Nz6BByujX4ex1jGgKpO20SXcGMa78k405vNV_4uJ1UDk_b-0-regi5x96KRcaOMH"
})
}).then((response) => {
//HttpResult = response.content.toJSON();
console.log('----------------------------------------------------');
console.log(response);
}, (e) => {
console.log("Error occurred " + JSON.stringify(e));
});
},
the response is as below.
JS: ----------------------------------------------------
JS: {
JS: "content": {
JS: "multicast_id": 5720873045813109000,
JS: "success": 1,
JS: "failure": 0,
JS: "canonical_ids": 0,
JS: "results": [
JS: {
JS: "message_id": "0:1548488437363910%0000000000000000"
JS: }
JS: ]
JS: },
JS: "statusCode": 200,
JS: "headers": {
JS: "null": "HTTP/1.1 200 OK",
JS: "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"44,43,39\"",
JS: "Cache-Control": "private, max-age=0",
JS: "Content-Encoding": "gzip",
JS: "Content-Type": "application/json; charset=UTF-8",
JS: "Date": "Sat, 26 Jan 2019 07:40:37 GMT",
JS: "Expires": "Sat, 26 Jan 2019 07:40:37 GMT",
JS: "Server": "GSE",
JS: "Transfer-Encoding": "chunked",
JS: "X-Android-Received-Millis": "1548488436596",
JS: "X-Android-Response-Source": "NETWORK 200",
JS: "X-Android-Selected-Protocol": "http/1.1",
JS: "X-Android-Sent-Millis": "1548488436437",
JS: "X-Content-Type-Options": "nosniff",
JS: "X-Frame-Options": "SAMEORIGIN",
JS: "X-XSS-Protection": "1; mode=block"
JS: }
JS: }
even it says success. i have not got any notification on android. i'm not using ios.
I am fairly new here, but I realized you are much more likely to get a solution to your problem if you post your Nativescript code here, along with your questions. That way, we can look to see where your code is failing. Regarding this plugin, I will tell you it is imperative you follow every step in the readme file that comes with the plugin. I also had a heck of a time getting this to work, but now I have push notifications working.
Here is an example of NativeScript push notifications in action. This app will also teach you how they achieved their Push Notifications. These are the nicest Push Notifications I have run across yet. NativeScript Push Notification Examples
Please post your page XML and js code-behind, and we'll have a look. Also be sure this value is set properly, as this caused me a headache. Good luck, post your code so we can help!
Tip: Make sure your project number exactly matched your Firebase project value.
var pushSettings = {
senderID: "<ENTER_YOUR_PROJECT_NUMBER>", // Required: setting with the sender/project number
notificationCallbackAndroid: function (stringifiedData, fcmNotification) {
var notificationBody = fcmNotification && fcmNotification.getBody();
_this.updateMessage("Message received!\n" + notificationBody + "\n" + stringifiedData);
}
};

Login Error in Firebase for Nativescript

Hi i try to instance my password login in nativescript but send me this error:
JS: error con login por email Logging in the user failed. com.google.firebase.FirebaseException: An internal error has occurred. [ {
JS: "error":{
JS: "code": 400,
JS: "message": "USER_NOT_FOUND",
JS: "errors": [
JS: {
JS: "message": "USER_NOT_FOUND",
JS: "domain": "global",
JS: "reason": "invalid"
JS: }
JS: ]
JS: }
JS: } ]
here is my code:
constructor() {
firebase.login({
type: firebase.LoginType.PASSWORD,
passwordOptions: {
email: 'test#test.com',
password: 'test#test.com'
}
}).then((user)=>{
console.dir(user);
}, (error)=>{
console.log("error con login por email "+ error);
}
)
}
can you help me to find why gives me that error?
when I login anonymous doesn't have errors
check if you don't forget to enable email-password login in your firebase instance.
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/docs/AUTHENTICATION.md#email-password-login

Customize JSON output of Forms/FormErrors

I would like to customize the JSON output of all the SymfonyForms in my Application. Since this is the first time I am building such an Application I am unsure about the best place to put the code to. Right now I see two options:
A custom Handler within the FOSRestBundle as described here
A Handler within the JMSSerializerBundle as mentioned here
I guess that both ways will do the Job, but which one should I prefer here in terms of flexibility and maintainability. As already said above, I would like to change the output for ALL forms and the validation errors in my application. It would be very nice if a little example would be provided.
Right now I get this output if a validation Error occurs:
{
"code": 400,
"message": "Validation Failed",
"errors": {
"children": {
"username": {},
"password": {
"children": {
"first": {},
"second": {}
}
},
"email": {
"errors": ["This value is already used."]
}
}
}
}
And would like to have something like that:
{
"code": …,
"message": …,
"errors": {
"<formname>": {
…
"email": "This value is already used." //errors concatenated to a string
…
}
}
}
Thanks in ahead!

Google Analytics Reporting API V4 Lifetime value requests - invalid dimensions/metrics

I'm trying to make calls the Analytics Reporting API V4 and keep getting back unspecific error messages when trying to use certain dimensions and metrics. For example, I consistently get
{
"error": {
"code": 400,
"message": "Unknown dimension(s): ga:acquisitionTrafficChannel",
"status": "INVALID_ARGUMENT"
}
}
when passing ga:acquisitionTrafficChannel, despite it being documented as a valid dimension. Similarly, I get
{
"error": {
"code": 400,
"message": "Selected dimensions and metrics cannot be queried together.",
"status": "INVALID_ARGUMENT"
}
}
when passing ga:acquisitionSourceMedium (documented here), even when not passing any metrics whatsoever.
Are the docs out of date? Is there some documentation elsewhere about valid combinations of dimensions and metrics?
All the Lifetime Value reports and thus ga:acquisition... dimensions are only valid for App views not web views.
Secondly the cohort/LTV dimensions can only be queried in within a cohort requests for example:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests": [
{
"viewId": "XXXX",
"dimensions": [
{
"name": "ga:cohort"
},
{
"name": "ga:acquisitionTrafficChannel"
}
],
"metrics": [
{
"expression": "ga:cohortSessionsPerUser"
}
],
"cohortGroup": {
"cohorts": [
{
"name": "cohort 1",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"startDate": "2015-08-01",
"endDate": "2015-09-01"
}
},
{
"name": "cohort 2",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"startDate": "2015-07-01",
"endDate": "2015-08-01"
}
}
],
"lifetimeValue": true
}
}
]
}
The error messages should probably be a bit clearer.
I ran into this problem as well. When I was in the Google Analytics Dashboard, I clicked on Acquisition->All Traffic->Channels and was fooled into thinking that I needed to combine the ga:acquisitionMedium dimension and ga:newUsers metric together.
When I clicked on ga:acquisitionMedium, it said that combining it with ga:newUsers was valid, despite the error that you mentioned in your question! In reality, I just needed to combine ga:medium and ga:newUsers together.
I know this is not the exact query that you were doing, but here is an example of how I queried New Users count where the dimension channel equaled "organic" (note that I am forming the JSON request with Javascript and then using JSON.stringify(req) to send it):
var req = {
reportRequests: [{
viewId: '<Your Google Analytics view ID>',
dimensions: [{ name: 'ga:medium' }],
dimensionFilterClauses: [{
filters: [{
dimensionName: 'ga:medium',
operator: 'EXACT',
expressions: ['organic']
}]
}],
dateRanges: [{ startDate: '2019-11-01', endDate: '2019-11-30' }],
metrics: [{ expression: "ga:newUsers" }]
}]
};
The above query returns 5,654, which is the same as seen in the "Acquisition" section of Google Analytics.
I definitely think the documentation and error message around this could be improved.

Resources