I am writing an angular code to give permission to another account to access a particular file in google drive.
public async givepremission(fileid,email){
await gapi.client.setApiKey(this.credconst.APIkey.toString());
return await gapi.client.load("drive","v3")
.then(async () =>
{
return await gapi.client.drive.permissions.create({
"fileId": fileid,
"resource": {
"role": "reader",
"type": "user",
"emailAddress": email
}
}) },
(err) => {
this.toastr.error('Google API error');
throw(err);
});
}
But all i am getting is an error
domain: "global"
reason: "required"
message: "Permission value field required"
locationType: "other"
location: "permission.value"
I tried it in the https://developers.google.com/drive/api/v3/reference/permissions/create Try This API there it is working fine but in my project it throws the above error.
The account I am using to give permission is not a G-Suite user.
I have no idea why this error pops up?
How can I solve this issue?
-Thanks
if you have a look here https://developers.google.com/drive/api/v2/reference/permissions/insert
under "Optional Properties" you have the value field
here's the requestBody you should pass:
requestBody:{
emailAddress:'fabrizio#keyko.io',
role:'writer',
type:'user',
value: 'fabrizio#keyko.io'
},
I had the same error but now it works for me.
Related
due to well-known N+1 problem we decided to move away from #ResolveField() feature of NestJS and use our implementation of DataLoader instead. By doing so, we must handle errors of resolvers manually because the resolution of graphql data is not driven by NestJS (or apollo) anymore.
This put us into a problem when we want to return a GraphQL error response (e.g. "Book not found") from graphql query in a standard manner like this:
{
"data": {
user: {
id: 1
book: null
}
}
"errors": [
{
"message": "Book not found",
"statusCode": 400
}
]
}
But since we are not using #ResolveField() anymore we resolve nested data (book) manually
we receive this response:
{
"data": null
"errors": [
{
"message": "Book not found",
"statusCode": 400
}
]
}
Is there any way to populate GraphQL error response manually?
#Query(() => User)
async user(#Args('id') id: number): Promise<User> {
const user = await this.userService.findOne(id);
try{
const book = await this.bookService.findOne(user.bookId);
user.book = book;
} catch (e) {
// How to populate GraphQL error response manually?
user.book = null;
}
return user;
}
Thanks for your help and have a nice day!
I am new to plaid.
I created a plaid access_token and now its showing
"error_code":"ITEM_LOGIN_REQUIRED"
Using the doc I understand that we need to use update mode for solving this
then access token will not change and no need to call token -exchange
after getting this error
I tried calling
https://sandbox.plaid.com/link/token/create
method -POST
{
"client_id": "xxxxxx",
"secret": "xxxxxx",
"client_name": "test",
"user": { "client_user_id": "xxxx" },
"country_codes": ["US"],
"language": "en",
"access_token": "access-sandbox-xxxx-xxx-xxx-xxx-111111"
}
then I got new link_token
{
"expiration": "2021-11-09T13:46:12Z",
"link_token": "link-sandbox-xxxx-xxx-xxxx-xxx-xxx",
"request_id": "xxxxx"
}
Then after what I need to do ?? .. I understand that no need to do token exchange api.
but if I tried to use this api using the existing access-token it is showing the same error
https://sandbox.plaid.com/accounts/get
method -POST
{
"client_id": "xxxxxx",
"secret": "xxxxxx",
"access_token": "access-sandbox-xxxx-xxx-xxx-xxx-111111"
}
output
{
"display_message": null,
"error_code": "ITEM_LOGIN_REQUIRED",
"error_message": "the login details of this item have changed (credentials, MFA, or required user action) and a user login is required to update this information. use Link's update mode to restore the item to a good state",
"error_type": "ITEM_ERROR",
"request_id": "3LMjpQHxYAMDwos",
"suggested_action": null
}
in that document they are saying like this.
An Item's access_token does not change when using Link in update mode, so there is no need to repeat the exchange token process.
then why I am getting again this ??
What I need to do solve this issue?
// Initialize Link with the token parameter
// set to the generated link_token for the Item
const linkHandler = Plaid.create({
token: 'GENERATED_LINK_TOKEN',
onSuccess: (public_token, metadata) => {
// You do not need to repeat the /item/public_token/exchange
// process when a user uses Link in update mode.
// The Item's access_token has not changed.
},
onExit: (err, metadata) => {
// The user exited the Link flow.
if (err != null) {
// The user encountered a Plaid API error prior
// to exiting.
}
// metadata contains the most recent API request ID and the
// Link session ID. Storing this information is helpful
// for support.
},
});
After getting the Link token, you need to initialize Link with the Link token. Per the docs:
"To use update mode for an Item, initialize Link with a link_token configured with the access_token for the Item that you wish to update."
https://plaid.com/docs/link/update-mode/
Once the user has successfully completed the Link flow, the access token should be reactivated.
Using Gmail API to read my mailbox. The message reading process is working as expected but I want to change the label of reading messages just for acknowledgment purposes so that I can have track of the reading messages list in my Gmail inbox only. Tried given two methods to change the label but non of them worked for me. Need suggestion on the same
Methods:
Codebase is written in Golang (as a backend)
Tried with Google API Explorer
(METHOD 1) -
Go sample code:
gmsg: = gmail.ModifyMessageRequest {
RemoveLabelIds: [] string {
"INBOX". //system defined label
},
AddLabelIds: [] string {
"INBOXING" //my custom label. created through Gmail
},
}
_, errDelete: = gService.Users.Messages.Modify("me", messageid, &gmsg).Do()
if (errDelete != nil) {
logs.Error("GMAIL SERVICE ERROR:: for [", accountEmail, "] while moving message to [INBOXING] folder ", errDelete.Error())
}
Got below error :
{"level":"error","msg":"GMAIL SERVICE ERROR:: for [sample#gmail.com] while moving message to [INBOXING] folder googleapi: Error 400: Invalid label: INBOXING, invalidArgument","time":"2021-08-09 20:05:13"}
(METHOD 1) -
Gmail Modify API
Payload
{
"addLabelIds": [
"INBOXING"
],
"removeLabelIds": [
"INBOX"
]
}
Response from Google API -
{
"error": {
"code": 400,
"message": "Invalid label: INBOXING",
"errors": [
{
"message": "Invalid label: INBOXING",
"domain": "global",
"reason": "invalidArgument"
}
],
"status": "INVALID_ARGUMENT"
}
}
Observation - *
On modifying message with custom label's Gmail API return's 400 bad
request, but if we request with system labels it allows us to modify
the label.
You are using the label name instead of label id. To obtain the label id, you have to use the Method: users.labels.list
Response:
Once you have the ID, you can now use it in Method: users.messages.modify
Request body:
Response:
From the web api reference here
I tried querying the api with no luck of success specially with the parameter Schedules being stated as type string.
1.) For msdyn_BookingResource
POST: https://bhaud365dev.crm6.dynamics.com/api/data/v9.0/msdyn_BookingResource
BODY:
{"ResourceId":[GUID],"BookingStatusId":[GUID],"BookingMethod":690970003,"BookingType":1,"Schedules":"[{\"StartDateTime\":\"2019-07-15T00:00:00Z\",\"EndDateTime\":\"2019-07-19T00:00:00Z\"}]","Timeframe":5}
RESPONSE: {
"error": {
"code": "0x80040224",
"message": "The added or subtracted value results in an un-representable DateTime.\r\nParameter name: value",
2.) For msdyn_BookingResourceRequirement
POST: https://bhaud365dev.crm6.dynamics.com/api/data/v9.1/msdyn_resourcerequirements([GUID])/Microsoft.Dynamics.CRM.msdyn_BookingResourceRequirement
BODY: {
"BookingMethod": 690970003,
"BookingStatusId": [GUID],
"BookingType": 1,
"EndDateTime": "2019-07-19T07:29:00Z",
"ResourceId": [GUID],
"StartDateTime": "2019-07-15T22:00:00Z"
}
RESPONSE: {
"error": {
"code": "0x80040224",
"message": "Object reference not set to an instance of an object.",
I was able to api query for functions but for the actions I am stuck and I am not sure on what am I doing wrong. Any tips or example is greatly appreciated.
BTW. tried the above queries also in CRM REST BUILDER v2.6.0.0 Same error responses.
I spent some time, getting same weird error and then I realized they are Internal Use only Actions. It's not intended for our usage & it's highly unsupported as they tend to break in future versions when Microsoft planned to change.
I was able to successfully create the Bookable Resource Bookings with the help of below web api request.
var entity = {};
entity["Resource#odata.bind"] = "/bookableresources(7B203E2F-F2FB-E911-A813-000D3A5A1BF8)";
entity["BookingStatus#odata.bind"] = "/bookingstatuses(026BDCEF-9257-4C10-9E49-C92539B883D6)";
entity["endtime"] = "2019-11-07T21:00:00Z";
entity["starttime"] = "2019-11-07T20:00:00Z"
entity.bookingtype = 1;
entity.msdyn_bookingmethod = 690970003;
Xrm.WebApi.online.createRecord("bookableresourcebooking", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
I develop my first Laravel application with Vue-js in SPA.
I try to forbid access to a route (view-router) through a role.
For roles, I use the spatie/laravel-permission package.
I set up view-auth rolesVar like this:
const config = {
rolesVar: 'roles',
…
}
Here is an example of a user in json
{
"status":"success",
"data":{
"id":1,
"first_name":"John",
"last_name":"Doe",
"email":"john#Doe",
"created_at":"2019-07-11 11:20:20",
"updated_at":"2019-07-11 11:20:20",
"all_permissions":[
],
"can":[
],
"permissions":[
],
"roles":[
{
"id":1,
"name":"super-admin",
"guard_name":"api",
"created_at":"2019-07-11 11:20:20",
"updated_at":"2019-07-11 11:20:20",
"pivot":{
"model_id":1,
"role_id":1,
"model_type":"App\\Models\\User"
},
"permissions":[
]
}
]
}
}
I try to force my role like this, but it does not work. I am redirected to / 403 (as requested).
I conclude that he does not take my role.
{
path: '/admin',
name: 'admin.dashboard',
component: AdminDashboard,
meta: {
auth: {
roles: { name: 'super-admin' },
redirect: { name: 'login' },
forbiddenRedirect: { path: '/403' }
}
}
},
I think it's because I have several json objects in "roles" but I don't know what to call it for it to work
Thanks for your help !
use server side security instead of client side like this
Route::group(['middleware' => ['permission:permission1|permission2']], function () {
Route::get('/protected_URL',function(){
return "I can only access this if i only have permission1 and permission2";
});
});
this was only authenticated user and user having "permission1" and "permission2" have access to this page, otherwise it will thought access denied error where you can easily catch this error with axios and display Access Denied message