Flask google authentification offline keep - python

I followed this tutorial for the authentification with google account in the flask.
As was written in this tutorial the response as the JSON is:
{
"family_name": "Doe",
"name": "John Doe",
"picture": "https://lh3.googleusercontent.com/-asdasdas/asdasdad/asdasd/daadsas/photo.jpg",
"locale": "en",
"gender": "male",
"email": "john#gmail.com",
"link": "https://plus.google.com/+JohnDoe",
"given_name": "John",
"id": "1109367330250025112153346",
"verified_email": true
}
I fetch this JSON response to my database and trying to login in offline mode. In other words, I added one more "group" column to the response and base that column redirect users to the different pages. When I try to log in again with this credentials after login page it opens a blank page without any error. My question how can I keep google user credentials in the flask at offline mode. Thank you for reading

You can't keep it by this way because oath token will update each time. But you can update user data, at the base of the email. Read this guide

Related

can't create payment invoice without redirecting

I want to accept money through paypal. I need to send the user a link and get paid. The approval_link link is being created successfully. But it is not possible to pay using the link. I log in using this link, click pay, but I am redirected to return_url. I don't want this, I want the user not to be redirected anywhere. You just need to take the money from him and that's it. My project is not a website and I don't have any pages where you can redirect the client. Help to create a payment form without redirecting the client to other pages. I thank you in advance for the attention you paid to my problem and I apologize for my English.
I will repeat briefly: we need a payment form without redirecting to other pages. Just get the money. Please help to configure the parameters of paypalrestsdk.Payment()
import paypalrestsdk
api = paypalrestsdk.set_config(
mode="sandbox",
client_id="XXX",
client_secret="XXX")
token = api.get_access_token()
print(token)
payment = paypalrestsdk.Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"},
"redirect_urls": {
"return_url": "http://localhost:3000/process",
"cancel_url": "http://localhost:3000/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "RUB",
"quantity": 1}]},
"amount": {
"total": "1.00",
"currency": "RUB"},
"description": "This is the payment transaction description."}]})
create = payment.create()
if create:
print("Payment created successfully")
else:
print(payment.error)
for link in payment.links:
if link.rel == "approval_url":
# Convert to str to avoid Google App Engine Unicode issue
# https://github.com/paypal/rest-api-sdk-python/pull/58
approval_url = str(link.href)
print("Redirect for approval: %s" % (approval_url))
I tried not to specify links for redirects. If they are not present, the payment is not created.
First of all you are using a deprecated v1/payments API and corresponding SDK. If you were going to implement a website checkout, you should use the current v2/checkout/orders API and its SDK instead; such an integration is documented here.
But your invoice use case is not a normal website checkout, as you've noted. Indeed there is a separate Invoicing API for it, see the invoicing integration guide.
There's no SDK for invoicing APIs--use direct HTTPS API calls to first obtain an oauth2 access token and then create your invoice.

Can i build an application in python that will auto populate docusign fields from a google sheet?

I use docusign every day and have set up a google sheet that auto populates the email subject and body.
I'm still having to copy and paste this data into the 'email subject' & 'email message'. See screenshot example.
Is there a way i can reduce this process to the click of a button?
Absolutely. Here's are two rough flows that would be helpful to pursue.
You could make use of the Google Apps Script to push data directly to DocuSign. Downside here is that you'd be writing the code in JavaScript.
You can write a short python app yourself, which uses the Google Sheets API (via python sdk) to retrieve your data, then pass along the appropriate info to the DocuSign eSignature API (via python sdk).
In either case, once you have access to the data you wish to forward to DocuSign, you will want to first authenticate your account to make API requests on your behalf.
Then you can make a request like this:
POST /envelopes
{
"emailSubject": "Please sign these documents",
"emailBlurb": "Thank you for subscribing. Click the link to sign",
"documents": [
{
"documentBase64": "JVBER...iUlRU9GCg==",
"name": "Test Doc",
"fileExtension": "pdf",
"documentId": "1"
}
],
"recipients": {
"signers": [
{
"email": "test#test.com",
"name": "Test User",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"numberTabs": [
{
"tabLabel": "PO #",
"locked": "false",
"xPosition": "200",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1"
}
]
}
}
]
},
"status": "sent"
}

How to get envelope link

In my application, after user register, it creates a docusign document and send in an envelope to user's email for signature.
My question is how do I also provide a link to the document from my application? I want it to be the same link that user would access in their email. I have tried to construct url from envelope_id which i get from the result of create_envelope, but that seems to be wrong. Is there actually a way to do this? Or the it has to be accessed from user's email?
An envelope uri: envelopes/ids
The flow you might be looking for is called Embedded Signing. With embedded signing, you can redirect your users to sign DocuSign envelopes instead of having them sign via email.
Two steps process:
First, you will create your envelope. Be sure to include clientUserId for each recipient object. This will be used when you want to generate unique signing URLs in the next step.
POST /accounts/{accountId}/envelopes
{
"status": "sent",
"emailSubject": "Envelope with Embedded Signer",
"documents": [{
"documentId": "1",
"name": "contract.pdf",
"documentBase64": "base64 document bytes...",
}],
"recipients": {
"signers": [{
"email": "john#email.com",
"name": "John Doe",
"recipientId": "1",
"clientUserId": "1234"
}]
}
}
Second, you will generate the RecipientViewURL for a given user.
POST /accounts/{accountId}/envelopes/{envelopeId}/views/recipient
{
"userName": "John Doe",
"email": "johndoe#email.com",
"recipientId": "1",
"clientUserId": "1234",
"authenticationMethod": "email",
"returnUrl": "https://www.docusign.com/devcenter"
}
Here is a guide that provides a more thorough background on the feature.

Login to Instagram and follow one account

I want to give 10 complimentary followers to the users who enter their Instagram username on my website.
I have pre-registered 10 Instagram profiles for this. ( E.g. IGprofile1, Igprofile2...Igprofile10).
When a user enters his username (E.g. kimkardashian) on the form and click submit, it'll be sent to my web server and give 10 followers to "kimkardashian"
IGprofile1-->login-->follow "kimkardashian" -->logout
IGprofile2-->login-->follow "kimkardashian" -->logout
....
....
IGprofile10-->login-->follow "kimkardashian" -->logout
I need this to on my server.
Below is a code one of my friend gave me
Any expert idea will be greatly appreciated.
.
"""
Follow
"""
import argparse
import sys
import os
from tqdm import tqdm
sys.path.append(os.path.join(sys.path[0], '../'))
from instabot import Bot
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('user', type=str, help='user')
args = parser.parse_args()
# Add your bots here
BOTS_DATA = [
{
"username": "user1",
"password": "pass1",
"proxy": "https://127.0.0.1:3128"
},
{
"username": "user2",
"password": "pass2",
"proxy": "https://127.0.0.1:3128"
},
{
"username": "user3",
"password": "pass3",
"proxy": "https://127.0.0.1:3128"
},
{
"username": "user4",
"password": "pass4",
"proxy": "https://127.0.0.1:3128"
},
]
for bot in tqdm(BOTS_DATA):
bot['bot'] = Bot()
bot['bot'].login(username=bot['username'], password=bot['password'], proxy=bot['proxy'])
bot['bot'].follow(args.user)
The only way to follow another user's account would be through using Instagram's API. Unfortunately, Instagram has recently stopped accepting applications for the relationships scope which permits such an action — refer to the Instagram documents here.
I cannot offer any advice on the matter, but you will also want to ensure you're building an application which aligns with Instagram's Terms of Use and Platform Policy.
An alternative option to explore might be to look at automation with twill, for example — How can I login to a website with Python?

Cannot get Pagination on a list of followers at Instagram API

I am trying to get the list of followers via Instagram API.
At the process, Instagram API does not give me a key of pagination as follows.
I'm at Sandbox mode and creating the app for passing the review of Instagram API. Also tried to get data directly via Python library but still does not work.
Could you tell me how to get a key of pagination?
from instagram.client import InstagramAPI
access_token = "ACCESS_TOKEN"
client_secret = "CLIENT_SECRET"
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
followed_by, next = api.user_followed_by()
print next # -> None
# 'pagination' key is empty.
# https://api.instagram.com/v1/users/self/followed-by.json?access_token=ACCESS_TOKEN
# {
# "pagination": {},
# "data": [
# {
# "id": "1111111111",
# "username": "xxxx_xxxx",
# "full_name": "xxxxxxxxx",
# "profile_picture": "..."
# },
# {
# "id": "2222222222",
# "username": "yyyy_yyyy",
# "full_name": "yyyyyyyyy",
# "profile_picture": "..."
# },
# ],
# "meta": {"code": 200}
# }
You will not get pagination in sandbox mode, you will only get 20 items in response in sandbox mode, once you go live after approval, you will get pagination data to request more users.
https://www.instagram.com/developer/sandbox/
The behavior of the API when you are in sandbox mode is the same as
when your app is live, but comes with the following restrictions:
Data is restricted to sandbox users and the 20 most recent media from each sandbox user

Categories

Resources