當前位置: 首頁>>代碼示例>>Python>>正文


Python Meli.authorize方法代碼示例

本文整理匯總了Python中melisdk.meli.Meli.authorize方法的典型用法代碼示例。如果您正苦於以下問題:Python Meli.authorize方法的具體用法?Python Meli.authorize怎麽用?Python Meli.authorize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在melisdk.meli.Meli的用法示例。


在下文中一共展示了Meli.authorize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: index

# 需要導入模塊: from melisdk.meli import Meli [as 別名]
# 或者: from melisdk.meli.Meli import authorize [as 別名]
    def index(self, **codes):
        cr, uid, context = request.cr, request.uid, request.context
        company = request.registry.get("res.company").browse(cr, uid, 1)
        CLIENT_ID = company.mercadolibre_client_id
        CLIENT_SECRET = company.mercadolibre_secret_key

        meli = Meli(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)

        codes.setdefault("code", "none")
        codes.setdefault("error", "none")
        codes.setdefault("error_description", "none")
        if codes["error"] != "none":
            message = "ERROR: %s" % codes["error"]
            message += " DESCRIPTION: %s" % codes["error_description"]
            return "<h1>" + message + "</h1><br/><a href='" + meli.auth_url(redirect_URI=REDIRECT_URI) + "'>Login</a>"

        if codes["code"] != "none":
            print "Meli: Authorize: REDIRECT_URI: %s, code: %s" % (REDIRECT_URI, codes["code"])
            meli.authorize(codes["code"], REDIRECT_URI)
            ACCESS_TOKEN = meli.access_token
            REFRESH_TOKEN = meli.refresh_token
            company.write(
                {
                    "mercadolibre_access_token": ACCESS_TOKEN,
                    "mercadolibre_refresh_token": REFRESH_TOKEN,
                    "mercadolibre_code": codes["code"],
                }
            )
            return (
                'LOGGED WIT CODE: %s <br>ACCESS_TOKEN: %s <br>REFRESH_TOKEN: %s <br>MercadoLibre for Odoo 8 - Moldeo Interactive <br><a href="javascript:window.history.go(-2);">Volver a Odoo</a> <script>window.history.go(-2)</script>'
                % (codes["code"], ACCESS_TOKEN, REFRESH_TOKEN)
            )
        else:
            return "<a href='" + meli.auth_url(redirect_URI=REDIRECT_URI) + "'>Login</a>"
開發者ID:Richardgh83,項目名稱:meli_oerp,代碼行數:36,代碼來源:controllers.py

示例2: index

# 需要導入模塊: from melisdk.meli import Meli [as 別名]
# 或者: from melisdk.meli.Meli import authorize [as 別名]
    def index(self, **codes ):
        cr, uid, context = request.cr, request.uid, request.context
        company = request.registry.get('res.company').browse(cr,uid,1)
        CLIENT_ID = company.mercadolibre_client_id
        CLIENT_SECRET = company.mercadolibre_secret_key

        meli = Meli(client_id=CLIENT_ID,client_secret=CLIENT_SECRET)

        codes.setdefault('code','none')
        codes.setdefault('error','none')
        if codes['error']!='none':
            message = "ERROR: %s" % codes['error']            
            return "<h1>"+message+"</h1><br/><a href='"+meli.auth_url(redirect_URI=REDIRECT_URI)+"'>Login</a>"

        if codes['code']!='none':
            print "Meli: Authorize: REDIRECT_URI: %s, code: %s" % ( REDIRECT_URI, codes['code'] )
            meli.authorize( codes['code'], REDIRECT_URI)
            ACCESS_TOKEN = meli.access_token
            REFRESH_TOKEN = meli.refresh_token
            company.write({'mercadolibre_access_token': ACCESS_TOKEN, 'mercadolibre_refresh_token': REFRESH_TOKEN, 'mercadolibre_code': codes['code'] } )
            return 'LOGGED WIT CODE: %s <br>ACCESS_TOKEN: %s <br>REFRESH_TOKEN: %s <br>MercadoLibre for Odoo 8 - Moldeo Interactive <br><a href="javascript:window.history.go(-2);">Volver a Odoo</a> <script>window.history.go(-2)</script>' % ( codes['code'], ACCESS_TOKEN, REFRESH_TOKEN )
        else:
            return "<a href='"+meli.auth_url(redirect_URI=REDIRECT_URI)+"'>Login</a>"
開發者ID:lertech,項目名稱:meli_oerp,代碼行數:25,代碼來源:controllers.py


注:本文中的melisdk.meli.Meli.authorize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。