Çöó½ºÅ© - ¿ÀµåÅ©Çöó½ºÅ©¿¡ ODESK API Áö¿øÀ» Ãß°¡ÇÕ´Ï´Ù. | |
Áö±Ý ´Ù¿î·Îµå |
Çöó½ºÅ© - ¿ÀµåÅ© ¼øÀ§ ¹× ¿ä¾à
±¤°í
Çöó½ºÅ© - ¿ÀµåÅ© ű×
Çöó½ºÅ© - ¿ÀµåÅ© ¼³¸í
Çöó½ºÅ©¿¡ Odesk API Áö¿øÀ» Ãß°¡ÇÕ´Ï´Ù Flask-Odesk´Â ODESK API Áö¿øÀ» Ãß°¡ÇÏ´Â Çöó½ºÅ© È®ÀåÀÔ´Ï´Ù. ODESK API¸¦ »ç¿ëÇÒ ¼ö ÀÖÀ¸¹Ç·Î API Å°¸¦ ¾ò¾î¾ßÇÕ´Ï´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº ODESK API ¼¾ÅÍ ¹®¼¸¦ ¹æ¹®ÇϽʽÿÀ. Flask-Odesk´Â OAuth¸¦ ÅëÇØ ½ÂÀÎÀ» »ç¿ëÇϸç ÀÎÁõ À¯Çü "OAuth"°¡ÀÖ´Â Å°°¡ ÇÊ¿äÇÕ´Ï´Ù. Secure ÄíÅ°¸¦ ±â¹ÝÀ¸·Î ¼¼¼Ç¿¡ ÇÊ¿äÇÑ Secret_Key°¡ Settings.py:secret_key = '·Î Ç¥½ÃµË´Ï´Ù. (ÀÓÀÇÀÇ ºñ¹Ð Å°) '½ÖÀÇ ODESK API Å°¸¦ ¼³Á¤ÇϽʽÿÀ. PDESK API Å°¸¦ ¼³Á¤ÇÕ´Ï´Ù. PDESK_KEY ='(ODESK °ø°³ Å°) 'ODESK_SECRET ='(ODESK Secret Key) 'ÆÀ ¸ñ·ÏÀ» ¼³Á¤ÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ¼³Á¤ .Py¿¡¼ ±ÇÇÑÀ» ºÎ¿© ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ¿É¼ÇÀ» ÁöÁ¤ÇÏÁö ¾Ê°Å³ª ¸ñ·ÏÀ» ºñ¿ö µÎÁö ¾ÊÀ¸¸é ¸ðµç ODESK »ç¿ëÀÚ°¡ ADESK_AUTH_TEAMS = ( 'ODESK : ODESKPSBOOTCAMP', ODESK : ODESKPSBOOTCAMP ', APP.PY¿¡ ODESK ¸ðµâ µî·ÏÀÌ ¿Ã¹Ù¸£°Ô µî·ÏµÇ¾î ÀÖ¾î¾ßÇÕ´Ï´Ù. ±× url_prefix´Â ´ç½ÅÀÌ ÁÁ¾ÆÇÏ´Â °ÍÀ» ¿°µÎ¿¡ µÎ¾î¾ßÇÕ´Ï´Ù. flask °¡Á® ¿À±â flaskfrom flaskext.odesk °¡Á® ¿À±â ODESKAPP = flask (__ À̸§ __) app.config.from_pyfile ( 'settings.py') app.register_module (Odesk, url_prefix = '/ odesk) ') AuthorizationPlease¸¦ »ç¿ëÇÏ¿© decorator login_required¸¦ »ç¿ëÇÏ¿© ÀÍ¸í »ç¿ëÀÚ¸¦ À¥ »çÀÌÆ®ÀÇ Æ¯Á¤ ºÎºÐÀ» ´ÝÀ¸·Á¸é @ app.route ('/ only / odesk / users ') @ odesk.login_requireddef admin () : ¹Ýȯ "ȯ¿µ" , ODESK »ç¿ëÀÚ! "ÅÛÇø´¿¡ ·Î±×ÀÎ ¶Ç´Â ·Î±× ¾Æ¿ô ¸µÅ©¸¦ ÁöÁ¤ÇÏ·Á¸é URL_FOR ÇÔ¼ö ¹× ODESK_IS_AUTHORIZED º¯¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. {% a odesk_is_authorized %} ·Î±× ¾Æ¿ô {% else %} odesk ·Î±×ÀÎ {% endif %}. ÇöÀç »ç¿ëÀÚ´Â is_authized ¸Þ¼Òµå¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. @ app.route ( '/ test') def test () : ODESK.IS_AUTHORIZE () ÀÎ °æ¿ì "½ÂÀÎÀ» ¹Þ¾Ò½À´Ï´Ù." else : "¾ÆÁ÷ ½ÂÀεÇÁö ¾Ê¾Ò½À´Ï´Ù."¶ó´Â ¸Þ½ÃÁö°¡ ÇÊ¿äÇÏÁö ¾ÊÀ¸¸é Äڵ忡¼ ¼öµ¿À¸·Î ±ÇÇÑ ÇÁ·Î¼¼½º¸¦ ½ÃÀÛÇÒ ¼ö ÀÖ½À´Ï´Ù. ODESK.IS_AUTHORIZE ()°¡ ¾Æ´Ñ °æ¿ì : return odesk.login () ´ÙÀ½ ¸Å°³ º¯¼ö¸¦ »ç¿ëÇÏ¿© URLÀ» ³ªÅ¸³¾ ¼öµµ ÀÖ½À´Ï´Ù. ±ÇÇÑ ÇÁ·Î¼¼½º°¡ ³¡³ ÈÄ ¸®µð·º¼Ç µÉ °ÍÀÔ´Ï´Ù. ODESK.IS_AUTHORIZEDE ()°¡ ¾Æ´Ñ °æ¿ì ODESK.LOGIN (´ÙÀ½ = '/ BLAH / BLAH')À» ¹ÝȯÇÕ´Ï´Ù. ·Î±× ¾Æ¿ô ¹æ¹ýÀ» »ç¿ëÇÏ¿© »ç¿ëÀÚÀÇ ·Î±× ¾Æ¿ôÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ·Î±×Àΰú ´Þ¸®ÀÌ ¸Þ¼µå¿Í ´Þ¸® ¸®µð·º¼ÇÀÇ ´ëºÎºÐÀ» ¹ÝȯÇÏÁö ¾Ê½À´Ï´Ù. ±×°ÍÀº ´Ü¼øÈ÷ OAuth ¼¼¼ÇÀ» »èÁ¦ÇÕ´Ï´Ù. odesk.is_authorized () : odesk.logout () retirect ( '/')¸¦ ¹ÝȯÇÏ´Â °æ¿ì ÀÚµ¿È ÇÁ·Î¼¼½º¸¦ È®ÀåÇÏ·Á¸é after_login decorator¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù, ÀÌ´Â ¼º°øÀûÀ¸·Î È£Ãâ µÉ ±â´ÉÀ» ³ªÅ¸³¾ ¼ö ÀÖ½À´Ï´Ù. ±ÇÇÑ ºÎ¿© : @ odesk.after_logindef save_session () : # ÇöÀç »ç¿ëÀÚÀÇ µ¥ÀÌÅÍ °¡Á® ¿À±â. Á¦¹ß, Ŭ¶óÀ̾ðÆ®¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀ» ÂüÁ¶ÇϽʽÿÀ. ¼¼¼Ç = odesk.get_client (). hr.get_user ( 'me') ¾ÖÇÁÅÍ _loginÀ» »ç¿ëÇÏ°í ¼¼¼Ç¿¡ ¹«¾ð°¡¸¦ ÀúÀå ÇÑ °æ¿ì, After_logoutÀ» »ç¿ëÇÏ¿© ·Î±× ¾Æ¿ô ÇÑ ÈÄÀÌ ¼¼¼ÇÀ» »èÁ¦ÇÏ´Â °ÍÀ» ÀØÁö ¸¶½Ê½Ã¿À. @ odesk.after_logoutdef delete_session () : ¼¼¼ÇÀÇ '»ç¿ëÀÚ'°¡ÀÖ´Â °æ¿ì, ClientYou¸¦ »ç¿ëÇϸé get_access_token ¸Þ¼Òµå¸¦ »ç¿ëÇÏ¿© ÇöÀç ¾×¼¼½º ÅäÅ« ¹× ¾×¼¼½º ÅäÅ« ºñ¹ÐÀ» °¡Á® ¿Í¼ ¾×¼¼½º¿¡ »ç¿ëµÉ ¼ö ÀÖ½À´Ï´Ù. ÇÊ¿äÇÑ °æ¿ì Ŭ¶óÀ̾ðÆ® : odesk.is_authized () : access_token, access_tokret = odesk.get_access_token () get_client ¸Þ¼Òµå¸¦ »ç¿ëÇÏ¿© Ŭ¶óÀ̾ðÆ®¸¦ ¾òÀ» ¼ö ÀÖ½À´Ï´Ù : c = odesk.get_client () c.team .get_teamrooms () ¶Ç´Â ÇöÀç »ç¿ëÀÚ°¡ ±ÇÇÑÀÌ ºÎ¿©µÇÁö ¾ÊÀº °æ¿ì¿¡µµ Ŭ¶óÀ̾ðÆ®¸¦ »ç¿ëÇÒ ¼ö ÀÖÁö¸¸ ¾×¼¼½º ÅäÅ« ¹× ¾×¼¼½º ÅäÅ« ¾ÏÈ£°¡ ¾ø½À´Ï´Ù : odesk.is_authorized ()°¡ ¾Æ´Ñ °æ¿ì : c = odesk.get_client (access_token, access_token_secret) c. Team.Get_TeamRooms () ¿ä±¸ »çÇ× : ¡¤ ÆÄÀ̽㠡¤ Çöó½ºÅ© ¡¤ Python-Odesk. ¡¤ OAUTH2.
Çöó½ºÅ© - ¿ÀµåÅ© °ü·Ã ¼ÒÇÁÆ®¿þ¾î