{"id":589,"date":"2016-09-07T18:07:59","date_gmt":"2016-09-07T09:07:59","guid":{"rendered":"http:\/\/www.nukoneko.info\/blog\/?p=589"},"modified":"2016-09-07T18:14:56","modified_gmt":"2016-09-07T09:14:56","slug":"google-appengine-%e3%81%a7%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%ab%e7%ab%8b%e3%81%a6%e3%81%9f%e3%82%b5%e3%83%bc%e3%83%90%e3%81%aeapi%e3%81%ab%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.nukoneko.info\/blog\/?p=589","title":{"rendered":"Google AppEngine \u3067\u30ed\u30fc\u30ab\u30eb\u306b\u7acb\u3066\u305f\u30b5\u30fc\u30d0\u306eAPI\u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>stub\u3084\u3089\u306a\u3093\u3061\u3083\u3089\u3067\u8ff7\u3063\u305f\u3051\u3069\u3001\u7d50\u5c40\u30b7\u30f3\u30d7\u30eb\u306b\u89e3\u6c7a\u3057\u305f<br \/>\n<!--more--><\/p>\n<h1>\u74b0\u5883<\/h1>\n<p>Mac OS Elcapitan<br \/>\nPython2.7<br \/>\nPyCharm<\/p>\n<p>GoogleAppEngine SDK \u3078\u306e\u30d1\u30b9\u306f\u65e2\u306b\u901a\u3057\u3066\u3042\u308a\u307e\u3059<\/p>\n<h1>\u5b9f\u88c5<\/h1>\n<p>ConfigureRemoteApi \u3092\u3044\u3044\u611f\u3058\u306b\u4f7f\u3046<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef initialize():\r\n  try:\r\n    import dev_appserver\r\n    dev_appserver.fix_sys_path()\r\n  except ImportError:\r\n    raise\r\n\r\n  app_id = 'dev~nkapp'\r\n  os.environ&#x5B;'APPLICATION_ID'] = app_id\r\n\r\n  # connect to local\r\n  def auth_func():\r\n    return &quot;dummy@example.com&quot;, &quot;passwd&quot;\r\n  from google.appengine.ext.remote_api import remote_api_stub\r\n  remote_api_stub.ConfigureRemoteApi(app_id, '\/_ah\/remote_api', auth_func, 'localhost:8080')\r\n<\/pre>\n<p>\u3053\u308c\u3092\u6700\u521d\u306b\u547c\u3093\u3067\u304a\u3051\u3070\u3001\u5f8c\u306f\u81ea\u7531\u306b\u30c7\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9\u51fa\u6765\u308b\u3002<\/p>\n<p>\u5b9f\u7528\u7684\u306b\u5207\u308a\u66ff\u3048\u308b\u306a\u3089\u3053\u3093\u306a\u611f\u3058<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# True-&gt;Local False-&gt;Remote\r\nSETTING_CONNECT_TO_LOCAL = True\r\n\r\nSETTING_APP_ID = 'nkapp'\r\nSETTING_API_PATH = '\/_ah\/remote_api'\r\n\r\nSETTING_LOCAL_SERVER_ADDR = 'localhost:8080'\r\n\r\ndef initialize():\r\n  app_id = SETTING_APP_ID\r\n  if SETTING_CONNECT_TO_LOCAL:\r\n    app_id = 'dev~' + SETTING_APP_ID\r\n  os.environ&#x5B;'APPLICATION_ID'] = app_id\r\n  try:\r\n    import dev_appserver\r\n    dev_appserver.fix_sys_path()\r\n  except ImportError:\r\n    raise\r\n\r\n  from google.appengine.ext.remote_api import remote_api_stub\r\n  if SETTING_CONNECT_TO_LOCAL:\r\n    # connect to local\r\n    def auth_func():\r\n      return &quot;dummy@example.com&quot;, &quot;passwd&quot;\r\n    remote_api_stub.ConfigureRemoteApi(app_id, SETTING_API_PATH, auth_func, SETTING_LOCAL_SERVER_ADDR)\r\n  else:\r\n    # connect to product\r\n    # app_name-???.json\r\n    os.environ&#x5B;'GOOGLE_APPLICATION_CREDENTIALS'] = '\/path\/to\/token\/app_name-???.json'\r\n    remote_api_stub.ConfigureRemoteApiForOAuth(&quot;%s.appspot.com&quot; % app_id, SETTING_API_PATH, secure=True)\r\n<\/pre>\n<h1>\u8ff7\u3063\u305f\u3068\u3053<\/h1>\n<p>\u6065\u305a\u304b\u3057\u306a\u304c\u3089&#8230;.  auth_func \u306e\u4e2d\u306e dummy@example.com \u3068 passwd \u306b\u4f55\u3092\u8a2d\u5b9a\u3059\u308c\u3070\u3044\u3044\u304b\u8ff7\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u3002\u3000\u305d\u306e\u307e\u307e\u3067\u554f\u984c\u306a\u3044\u3093\u3067\u3059\u306d(-\u03c9-  )<\/p>\n<p>\u697d\u3057\u3044GAE\u30e9\u30a4\u30d5\u3092<\/p>\n<p>\u3067\u306f\u3067\u306f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>stub\u3084\u3089\u306a\u3093\u3061\u3083\u3089\u3067\u8ff7\u3063\u305f\u3051\u3069\u3001\u7d50\u5c40\u30b7\u30f3\u30d7\u30eb\u306b\u89e3\u6c7a\u3057\u305f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,28],"tags":[],"class_list":["post-589","post","type-post","status-publish","format-standard","hentry","category-googleappengine","category-python"],"_links":{"self":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=589"}],"version-history":[{"count":6,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions"}],"predecessor-version":[{"id":595,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions\/595"}],"wp:attachment":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}