Google Drive Permissions API – security settings - python

We are working with Google Drive and Permissions API to get e-mail addresses of users with sharing permissions. The API might not return the e-mail address if user forbids this in Google+ profile.
The documentation to Google Drive Permissions API says:
The email address of the user this permission refers to. This is an output-only field which is populated when the permission type is user and the given user's Google+ profile privacy settings allow exposing their email address.
After few hours of searching, we cannot find this "profile privacy settings" in question. Google Account Settings shows no such field.
Anybody knows where it is?

With "profile privacy settings" they mean that the Google + profile have shared the email from the contact information with the profile you are authenticated for the request.
I've made some test with a couple of documents, both shared with "Anyone with the link can view", but the first is from a user that shares with me the email in contact information.
Using the Try It I get the following result:
{
"kind": "drive#permission",
"etag": "\"SQFIsIrlQ4j3H07nwR6GyVXbP4s/4mfL2lpQkyuoRKmfVUHuvQuo5DI\"",
"id": "yyyyyyyyyyyy",
"selfLink": "https://content.googleapis.com/drive/v2/files/1ypzfcjfxIusRz0rLoDYh49DqPUj9DdZJI3lCGLtCkn8/permissions/yyyyyyyyyyyyy",
"name": "NAME Surname",
"emailAddress": "KKKKK.XXXXX#gmail.com",
"domain": "gmail.com",
"role": "owner",
"type": "user",
"photoLink": "https://lh4.googleusercontent.com/-DRgxkD0Vigg/AAAAAAAAAAI/AAAAAAAAZ0g/dszVFwA6bUo/s64/photo.jpg"
}
The second file is from a test account that doesn't share the email with me.
And I get the following:
{
"kind": "drive#permission",
"etag": "\"SQFIsIrlQ4j3H07nwR6GyVXbP4s/eUBKpMiVeQhLf3_Rf4Us5qisOqU\"",
"id": "ooooooooookkkkkkk",
"selfLink": "https://content.googleapis.com/drive/v2/files/1IpGtyYgJ_K6b0Xp2TWuYrcCTfPrIGJoUrStMPCyWGgM/permissions/kkkkkkkkkk",
"name": "lkajdlkj oiuaoiuoi",
"domain": "gmail.com",
"role": "owner",
"type": "user",
"photoLink": "https://lh3.googleusercontent.com/-SUCY0jPNqsA/AAAAAAAAAAI/AAAAAAAAMEk/8Y7SD9VNhHE/s64/photo.jpg"
}
As you can see the emailAddress is not displayed in the second result
To change this setting in your Google+ profile follow this steps (or the official help page):
Go to your account on https://plus.google.com
When the page is loaded in the top left corner, hover to the Home Menu
Click on Profile
Open the About tab of your profile (top center)
Scroll down to the Contact Information and click edit
Home and Work contacts can be shared to different circles or remove all the circles to make the contacts fully private

Related

Stripe MetaData Working Properly But Not Showing Up on Stripe Dashboard

I've implemented Stripe checkout on a Django app and it's all working correctly except that it's not showing up on the Stripe Dashboard, even though it's showing in the event data on the same page. Have I formatted it incorrectly or am I overlooking something obvious?
This is how I added meta data:
checkout_session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items = line_itemz,
metadata={
"payment_type":"schedule_visit",
"visit_id":visit_id
},
mode='payment',
success_url= 'http://localhost:8000/success',
cancel_url = 'http://localhost:8000/cancel',)
Here is a screenshot of the Metadata section empty, but in the events the Metadata is there as it should be:
Again I can access the metadata every where else but would like it to show up on the dashboard so my team can more easily access that information.
The metadata field you set is for Checkout Session alone, but not on Payment Intent (which is the Dashboard page you are at). To have metadata shown at the Payment Intent, I'd suggest also setting payment_intent_data.metadata [0] in the request when creating a Checkout Session.
For example,
session = stripe.checkout.Session.create(
success_url="https://example.com/success",
cancel_url="https://example.com/cancel",
line_items=[
{
"price": "price_xxx",
"quantity": 1,
},
],
mode="payment",
metadata={
"payment_type": "schedule_visit",
"visit_id": "123"
},
payment_intent_data={
"metadata": {
"payment_type": "schedule_visit",
"visit_id": "123"
}
}
)
[0] https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata

get user profile photo from gmail api object

I build this google API client object,
serivce=build('gmail', 'v1', credentials=credentials)
i succed in founding the gmail address by doing this
serivce.users().getProfile(userId='me').execute()['emailAddress']
but I didn't found a way to get the Gmail user profile photo .
first- I tried to get it from getProfile but it only have history and other attributes.
then I tried some versions like getPhotos()/photos/getUrlPhoto but the service object doesn't have those attributes.
I would like to know how can I get from this object the user profile photo.
The Profile for a Gmail user contains the following information:
{
"emailAddress": string,
"messagesTotal": integer,
"threadsTotal": integer,
"historyId": string
}
Unfortunately, the profile photo is not one of them.
To retrieve a profile picture, you need to use the People API
Use the method people.get
Specify a resourceName (e.g. people/me) and set personFields to photos
This will return you the url(s) of the user's profile picture(s).
The response will look as follows:
{
"resourceName": "AAA",
"etag": "BBB",
"photos": [
{
"metadata": {
"primary": true,
"source": {
"type": "DOMAIN_PROFILE",
"id": "AAA"
}
},
"url": "https://lh3.googleusercontent.com/a-/CCC=s100"
}
]
}

PayPal REST live issues

I am using PayPal REST api using Python's paypalrestsdk.I have got 3 problems with my PayPal sell page:
the price of the item is not shown beside the cart icon. I've got only the icon with no text beside it.
the url is https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=XXXXXXXXX NOT like I've seen in many modern webapps https://www.paypal.com/webapps/hermes?token=XXXXXXX, what is the diffrence between the 2 urls?
I have no Pay with Debit or Credit Card button. This is only working in sandbox not in live
My payment object is as follows:
payment = Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": settings.HOME_URL + reverse('usr-pay-process'),
"cancel_url": settings.HOME_URL + reverse('usr-pay-cancel')
},
"transactions": [{
"amount": {
"total": "1.00",
"currency": "USD"
},
"description": "My Item"
}]
})
Check the below answers for your questions.
Q1. I see that item details are not passed on your CreatePayment API request, Pass the item details in the transaction object. Refer the following link for more information about Payments API: https://developer.paypal.com/docs/api/payments/
Q2. No answer. Check with PayPal support.
Q3. Check your PayPal live account email is confirmed, are you using personal or Business account. Also check if guest checkout/ account optional settings is enabled on your PayPal website preference. otherwise please contact PayPal support in the following URL: https://www.paypal-techsupport.com/app/ask

Get education history by id Facebook

I was trying to extract Facebook user profile by GraphAPI. From the query:"https://graph.facebook.com/v2.4/search?q=vietnam&limit=1000&offset=0&type=user&format=json&access_token=....". I can get the list of id Facebook. But I want more information about user profile such as education, email. I used query:"https://graph.facebook.com/v2.4/{id_user}?fields= education,birthday&access_token=...."But I cant get them. Any suggestions for my problem? I will highly appreciated
In order to obtain more detailed infos such as 'education', 'birthday' and 'email', you need an access token with permissions that will grant you access to that info.
From the graph API explorer, with the token you get by default, using the following query:
me?fields=id,name,education,email,birthday
will not return education, email or birthday
{
"id": "...",
"name": "..."
}
Using the Graph API Explorer tool, you can try the same query with more priviledges.
Click the "Get Token" button, then on the prompt you get, check the following permissions:
user_birthday
user_education_history
email (located inside "extended permissions")
then try the request again. You should get:
{
"id": "...",
"name": "...",
"email": "...#....com",
"birthday": "../../...."
"education": ...
}
NOTE: You may not get all fields, depending on wether the target user has made these fields available to you.
Also if the user you're querying is 'yourself' (/me) then the user must have granted these permissions to your app. (a user may decline individual permissions. Your app must take that in consideration and handle cases where permissions were refused.)
Once you've confirmed this works, all you have to do is to add these permissions to your login or authorization flow inside your app.

How to find users by their facebook uid in python social auth?

I have parsed the friends data from the graph api and now I have the "friends" data which include the id of the friends.Now I am looking for a way to find users by the id, to add the User objects to each other as friends.
I know how to find one user's uid.
user = User.objects.get(......)
user.social_auth.get(provider='facebook').uid
But how do I find User object by the uid?
You can just do a Request on URL:
https://graph.facebook.com/<UID>
{
"id": "358204548",
"first_name": "someName",
"gender": "male",
"last_name": "someLastName",
"locale": "en_US",
"name": "John Doe",
"username": "john.doe"
}
What you want is the User object, not the user info, right?
I can't find it in any documentation, so I am not sure what's the best way to do it. But I found that this is how social_core get the user object during the login proccess: https://github.com/python-social-auth/social-core/blob/df861e886f6984f813c1f1c5c9a0acffbe719e0d/social_core/pipeline/social_auth.py#L19
So this works for me:
from social_django.models import UserSocialAuth
user = UserSocialAuth.get_social_auth('facebook', uid).user
Hope this helps

Categories

Resources