Ejemplo n.º 1
0
def get_oauth_server():
    if not getattr(frappe.local, 'oauth_server', None):
        oauth_validator = OAuthWebRequestValidator()
        frappe.local.oauth_server = WebApplicationServer(oauth_validator)

    return frappe.local.oauth_server
Ejemplo n.º 2
0
from __future__ import unicode_literals
import frappe, json
from frappe.oauth import OAuthWebRequestValidator, WebApplicationServer
from oauthlib.oauth2 import FatalClientError, OAuth2Error
from urllib import quote, urlencode
from urlparse import urlparse
from frappe.integrations.doctype.oauth_provider_settings.oauth_provider_settings import get_oauth_settings

#Variables required across requests
oauth_validator = OAuthWebRequestValidator()
oauth_server = WebApplicationServer(oauth_validator)
credentials = None


def get_urlparams_from_kwargs(param_kwargs):
    arguments = param_kwargs
    if arguments.get("data"):
        arguments.pop("data")
    if arguments.get("cmd"):
        arguments.pop("cmd")

    return urlencode(arguments)


@frappe.whitelist()
def approve(*args, **kwargs):
    r = frappe.request
    uri = r.url
    http_method = r.method
    body = r.get_data()
    headers = r.headers