def login_via_paypal(): try: options = configure_openid_request() login_url = Tokeninfo.authorize_url(options=options) except (ConnectionError, MissingParam, MissingConfig) as e: app.logger.exception(e) return internal_server_error() except Exception as e: app.logger.exception(e) return internal_server_error() #redirect to login page for approval return redirect(login_url)
def login(request): # return render(request, 'paypal/google_validation.html', {}) print('Starting point') if 'logout_url' not in request.session: # Generate login url login_url = Tokeninfo.authorize_url( {"scope": "openid profile email"} ) #{ "scope": "openid profile email https://uri.paypal.com/services/expresscheckout"} return HttpResponseRedirect(login_url) else: return afterLogin(request)
def test_authorize_url_using_tokeninfo(self): url = Tokeninfo.authorize_url({ 'scope': 'openid profile' }) assert_regex_matches(self, url, 'scope=openid\+profile')
def get_connect_url(self, request): request.session['payment_paypal_oauth_event'] = request.event.pk self.init_api() return Tokeninfo.authorize_url({'scope': 'openid profile email'})
import paypalrestsdk from paypalrestsdk.openid_connect import Tokeninfo paypalrestsdk.configure({ 'openid_client_id': 'CLIENT_ID', 'openid_client_secret': 'CLIENT_SECRET', 'openid_redirect_uri': 'http://example.com' }) login_url = Tokeninfo.authorize_url({ 'scope': 'openid profile'}) print(login_url) code = raw_input('Authorize code: ') tokeninfo = Tokeninfo.create(code) print(tokeninfo) userinfo = tokeninfo.userinfo() print(userinfo) tokeninfo = tokeninfo.refresh() print(tokeninfo) logout_url = tokeninfo.logout_url() print(logout_url)
def test_authorize_url_using_tokeninfo(self): url = Tokeninfo.authorize_url({'scope': 'openid profile'}) assert_regex_matches(self, url, 'scope=openid\+profile')
def get_connect_url(self, request): request.session['payment_paypal_oauth_event'] = request.event.pk self.init_api() return Tokeninfo.authorize_url({'scope': 'openid profile email'})
# if payment.create(): # print("Payment[%s] created successfully" % (payment.id)) # # PayerID is required to approve the payment. # if payment.execute({"payer_id": "DUFRQ8GWYMJXC"}): # return True or False # print("Payment[%s] execute successfully" % (payment.id)) # else: # print(payment.error) # else: # print(payment.error) from paypalrestsdk.openid_connect import Tokeninfo, Userinfo # Generate login url login_url = Tokeninfo.authorize_url({ "scope": "openid profile"}) # Create tokeninfo with Authorize code tokeninfo = Tokeninfo.create("Replace with Authorize code") # Refresh tokeninfo tokeninfo = tokeninfo.refresh() # Create tokeninfo with refresh_token tokeninfo = Tokeninfo.create_with_refresh_token("Replace with refresh_token") # Get userinfo userinfo = tokeninfo.userinfo() # Get userinfo with access_token userinfo = Userinfo.get("Replace with access_token")