i have a slingshot configuration, this is work to s3 but i need to migrate a google storage. i have this
Slingshot.GoogleCloud.directiveDefault.GoogleSecretKey = Assets.getText('google-cloud-service-key.pem');
Slingshot.fileRestrictions( "myDefinedDirective", {
allowedFileTypes: [ "image/png", "image/jpeg", "image/gif" ],
maxSize: 1 * 1024 * 1024
});
Slingshot.createDirective( "myDefinedDirective", Slingshot.GoogleCloud, {
GoogleAccessId: "00b4903a97ce39dcfd2fdcd89772b588fdf77d22f74b0a5e57ea9553ce88d4d7",
bucket: "img_appengine",
acl: "public-read",
authorize: function () {
return true;
},
key: function ( file ) {
var user = Meteor.users.findOne( this.userId );
return user.emails[0].address + "/" + file.name;
}
});
i thinks, the problem its on GoogleAccessId, but i can't find this value!.
the error is
edgee_slingshot.js:390 POST https://img_appengine.storage.googleapis.com/ 403 ()transfer # edgee_slingshot.js:390(anonymous function) # edgee_slingshot.js:294(anonymous function) # edgee_slingshot.js:325(anonymous function) # dynamics_browser.js:51_maybeInvokeCallback # livedata_connection.js:446receiveResult # livedata_connection.js:466_livedata_result # livedata_connection.js:1631onMessage # livedata_connection.js:274(anonymous function) # stream_client_sockjs.js:172_.each._.forEach # underscore.js:105self.socket.onmessage # stream_client_sockjs.js:171REventTarget.dispatchEvent # sockjs-0.3.4.js:87SockJS._dispatchMessage # sockjs-0.3.4.js:1072SockJS._didMessage # sockjs-0.3.4.js:1130that.ws.onmessage # sockjs-0.3.4.js:1277
autoform-slingshot.coffee:143 errorClass {error: " - 403", reason: "Failed to upload file to cloud storage", details: undefined, message: "Failed to upload file to cloud storage [ - 403]", errorType: "Meteor.Error"}details: undefinederror: " - 403"errorType: "Meteor.Error"message: "Failed to upload file to cloud storage [ - 403]"reason: "Failed to upload file to cloud storage"stack: (...)get stack: stack()arguments: nullcaller: nulllength: 0name: "get stack"proto: ()set stack: stack()proto: Error(anonymous function) # autoform-slingshot.coffee:143(anonymous function) # edgee_slingshot.js:369
I believe you have the wrong accessId. It should look like an email address and is located in the 'manage service accounts' section of your service account keys
Related
I want to upload Powerpoint files to Google drive. When I do this using the UI (clicking on "Upload File" and uploading a file), things work as I expect. However, when I use the Drive API I get some formatting issues. For example, the shading (text highlight) in my Powerpoint tables is transparent, but when I upload to Drive using the API the shading becomes white.
I have tried to work around this by specifying MIME type as application/vnd.google-apps.file, but when I get the response, the MIME type shows as application/vnd.google-apps.presentation
I am using Google Drive API v3, accessed through the R package googledrive.
Try to use this mimeType : application/vnd.openxmlformats-officedocument.presentationml.presentation
including :
application/vnd.google-apps.file
Here is an example done with NodeJS, try and let me know if it works well for you.
Just in case, try other mimeTypes (url is provided on Reference list, scroll down)
var fileMetadata = {
'name': '___Your File Name Here___',
'mimeType': 'application/vnd.google-apps.file'
};
var media = {
mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
body: fs.createReadStream('___Your File Name Here___.pptx')
};
function uploadFile(auth){
const drive = google.drive({version: 'v3', auth});
drive.files.create({
resource: fileMetadata,
media: media,
fields: 'id'
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
})
}
// RUN script
fs.readFile('credentials.json', (err, content) => {
if (err) {
console.log('Error loading client secret file: ' + err);
return;
}
authorize(JSON.parse(content), uploadFile);
});
References:
Google mimeTypes (Google Reference)
List of mimeTypes (MDN)
Problem Description
My Android app collects data via Google Analytics for Firebase. For privacy reasons, users must be able to wipe their data off the Firebase servers, should they choose to do so.
The app requests a deletion by forwarding its Firebase APP_INSTANCE_ID to my own server. This server has been prepared in advance with credentials, from my personal Google account (via oauth2), for managing the Firebase project. The server authenticates with www.googleapis.com, and, using the supplied APP_INSTANCE_ID, invokes the upsert.
As noted by the documentation, the generic Google Analytics API is appropriate for this task.
After some initial trouble (b/c I didn't have the correct auth scope, and the Analytics API wasn't properly enabled), googleapis.com now returns HTTP 200 for each upsert request. (As an aside, even if you supply a bogus APP_INSTANCE_ID, it returns 200.)
Here is a sample response from the upsert, which shows nothing amiss:
{ kind: 'analytics#userDeletionRequest',
id:
{ type: 'APP_INSTANCE_ID',
userId: (REDACTED 32-char hexidecimal string) },
firebaseProjectId: (REDACTED),
deletionRequestTime: '2018-08-28T12:46:30.874Z' }
I know the firebaseProjectId is correct, because if I alter it, I get an error. I have verified that the APP_INSTANCE_ID is correct, and stable up until the moment it is reset with resetAnalyticsData().
Test Procedure
To test the deletions, I populated Firebase with several custom events, using the procedure below (Nexus 5X emulator, no Google Play, no Google accounts configured, but that shouldn't make any difference):
Install the app
Fire off some custom events (FirebaseAnalytics.logEvent)
Observe those events appear on the Firebase console
(About a minute later:) Make the upsert call, observe HTTP 200, and note the "deletionRequestTime"
Immediately call FirebaseAnalytics.resetAnalyticsData (to clear any event data cached on the device)
Uninstall the app
Rinse & repeat 7 or 8 times
However, even 24 hours later, 100% of the Firebase events are still present in the events table. No discernable state change has taken place on the Firebase server as a result of the upserts.
Question
So, what am I doing wrong? how do I successfully delete user data from Google Analytics for Firebase?
EDIT
Here's the code I'm using to make a request (from node.js):
const request = require( 'request' );
...
_deletePersonalData( data )
{
return new Promise( (resolve, reject) => {
request.post({
url: 'https://www.googleapis.com/analytics/v3/userDeletion/userDeletionRequests:upsert',
body: {
kind: 'analytics#userDeletionRequest',
id: {
type: 'APP_INSTANCE_ID',
userId: data.firebaseAppInstanceId
},
firebaseProjectId: (REDACTED)
},
headers: {
Authorization: 'Bearer ' + iap.getCurAccessToken()
},
json: true
}, (err, res, body) => {
console.log( 'user-deletion POST complete' );
console.log( 'Error ' + err );
console.log( 'Body ', body );
if( err )
{
reject( err );
return;
}
if( body.error )
{
reject( new Error( 'The Google service returned an error: ' + body.error.message + ' (' + body.error.code + ')' ) );
return;
}
resolve({ deletionRequestTime: body.deletionRequestTime });
});
});
}
Here's a sample request body:
{
kind: 'analytics#userDeletionRequest',
id: {
type: 'APP_INSTANCE_ID',
userId: (REDACTED 32-char hexidecimal string)
},
firebaseProjectId: (REDACTED)
}
And here's the console output for that same request (same userId and everything):
user-deletion POST complete
Error: null
Body: { kind: 'analytics#userDeletionRequest',
id:
{ type: 'APP_INSTANCE_ID',
userId: (REDACTED 32-char hexidecimal string) },
firebaseProjectId: (REDACTED),
deletionRequestTime: '2018-08-29T17:32:06.949Z' }
Firebase support just got back to me, and I quote:
Upsert method deletes any individual user data we have logged, but aggregate metrics are not recomputed. This means that you might not see any changes in the events tab in your Analytics console.
So, basically my mistake was expecting the events to disappear from the console.
This, of course, raises the question of how one determines that the API is actually working... but maybe the HTTP 200 is enough.
I installed a new Drupal 7.56 distribution.
I want to create new nodes via java client.
However, After little googling I found the “Services” module for Drupal 7.
So I installed it, with the next module:
Services
Ctools (required for Services)
Libraries (required for Services)
OAuth 1.0
So, I installed these modules. From the Structure menu I created the Service.
Endpoint: API
Server: REST
I enabled the Session and OAuth authentication.
I created a new Content type.
name: TestContent (Machine name: testcontent)
Fields:
Title (M.n.: title)
Body (M.n.: body)
Pics (M.n: field_pics) (Type: Image) Number of values: 5
In this Service I enabled all resource (file, user, etc..)
I Disabled the OAuth, because I will set up it later.
Now, I opened my Postman client.
Logging in: admin/admin
{
"sessid": "QZTYSQu3-I9pacOpoSP--V_LkGcusy2grl12U_CyKrY",
"session_name": "SESS51ebf8732a20744576a234cf7af43040",
"token": "jkUDb6MsGMHt_mBlGbm02O-lyZq-2nRTqD1OslxtvAg",
"user": {
"uid": "6",
"name": "admin",
…
Now I have a token. Now I upload two picture.
http://test.dd:8083/api/file
Got these responses
{
"fid": "6",
"uri": "http://test.dd:8083/api/file/6"
}
{
"fid": “7”,
"uri": "http://test.dd:8083/api/file/7”
}
Ok, Now I’ll try to create a new TestContent, and connect these Images to the node.
Ok, The node is created. But the Images isn’t connected to the node. But I didn’t get error message.
Why? What’s wrong?
I tried:
[ {fid:6} , {fid:7}]
und: [ { fid: 6 }]
Please give me ideas. Thank you
I found the solution on the Drupal site.
Run these GIT difference!
diff --git a/resources/node_resource.inc b/resources/node_resource.inc
index 8f870b7..6669a1a 100644
--- a/resources/node_resource.inc
+++ b/resources/node_resource.inc
## -339,8 +339,9 ## function _node_resource_create($node) {
);
$stub_form = drupal_build_form($node_type . '_node_form', $stub_form_state);
$form_state['triggering_element'] = $stub_form['actions']['submit'];
+ $node = (object) array_merge((array) $stub_node, (array) $node);
- drupal_form_submit($node_type . '_node_form', $form_state, (object)$stub_node);
+ drupal_form_submit($node_type . '_node_form', $form_state, $node);
if ($errors = form_get_errors()) {
return services_error(implode(" ", $errors), 406, array('form_errors' => $errors));
## -423,6 +424,7 ## function _node_resource_update($nid, $node) {
$node_type = $node['type'];
node_object_prepare($old_node);
+ $old_node = (object) array_merge((array) $old_node, (array) $node);
// Setup form_state.
$form_state = array();
diff --git a/resources/user_resource.inc b/resources/user_resource.inc
index 304a293..c1f9b5a 100644
--- a/resources/user_resource.inc
+++ b/resources/user_resource.inc
## -471,6 +471,7 ## function _user_resource_update($uid, $account) {
return services_error(t('You are not allowed to change your username.'), 406);
}
+ $account_loaded = (object) array_merge((array) $account_loaded, (array) $account);
$form_state['values']['op'] = variable_get('services_user_save_button_resource_update', t('Save'));
$form_state['values']['#user_category'] = $category;
$form_state['values']['#account'] = $account_loaded;
See more: Here
I've developed some google flex endpoints. They work locally but when I deploy the app (gcloud app deploy) I get a http status 403 forbidden. I'm using ajax to call the endpoint like this:
var echoEndpoint = function() {
$.ajax(userBaseUrl+'/echo', {
headers: {'Authorization': 'Bearer ' + userIdToken},
type: 'GET',
data: "key=my special key"
})
}
I'm protecting the endpoint with an apikey and passing the userIdToken in the header. The above code produces the 403 forbidden. But if I remove the header it works. albeit no user token. Here is the code that will NOT produce the 403
var echoEndpoint = function() {
$.ajax(userBaseUrl+'/echo', {
type: 'GET',
data: "key=my special key"
})
}
here is my paths section of my openapi.yaml
.....
paths:
"/echo":
get:
description: "Echo a test message."
operationId: "echo"
produces:
- "application/json"
responses:
200:
description: "Echo"
schema:
$ref: "#/definitions/echoMessage"
x-security:
- firebase:
audiences:
- "my project-id"
....
definitions:
echoMessage:
properties:
message:
type: "string"
Do I need to specify in my openapi.yaml that I'm sending a header in the request? If so how and where? I tried to put it in the definitions section but that yields a INVALID_ARGUMENT error when trying to deploy.
Did you define "firebase" in "securityDefinitions" as shown in this example (https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/endpoints/openapi.yaml#L108"?
I followed steps from https://github.com/Lepozepo/S3 to setup S3 upload with Meteor. I have created s3.js within server folder and placed
S3.config = {
key: 'accesskey',
secret: 'secretkey ',
bucket: 'my-bucket-name'
};
When i try to upload file to S3, i did not see any error. The callback function returns
Object { percent_uploaded: 100, uploading: false, url: "http://mybucket.s3.amazonaws.com/gfcNkm53mm2NNxGwY.jpg", secure_url: "https://mybucket.s3.amazonaws.com/gfcNkm53mm2NNxGwY.jpg", relative_url: "gfcNkm53mm2NNxGwY.jpg" }
on console.
But there is no file in my bucket on S3.
Also i added,
BrowserPolicy.content.allowOriginForAll('https://s3.amazonaws.com')
My CORS
AllowedOrigin - *, AllowedMethod - GET,PUT, POST, AllowedHeader - *
Bucket policy:
Also i added bucket policy.
I created bucket before 4 hour. May i know what is the issue?
Is it CORS issue?