OAuth2 for Apps Script - facebook

Google Apps Script에서 OAuth2 라이브러리를 사용하여 Facebook 서비스를 사용할 수 있습니다. 개발에 필요한 내용을 정리했습니다.

Google Apps script overview #your_first_script

The steps below show how to build and run a simplestandalone script that creates a Google Doc and emails you a link.

Set it up

  1. Visit script.google.com to open the script editor. (You'll need to be signed in to your Google account.) If this is the first time you've been toscript.google.com, you'll be redirected to a page that introduces Apps Script. Click Start Scripting to proceed to the script editor.
  2. A welcome screen will ask what kind of script you want to create. Click Blank Project or Close.
  3. Delete any code in the script editor and paste in the code below.

OAuth2 for Apps Script

OAuth2 for Apps Script is a library for Google Apps Script that provides the ability to create and authorize OAuth2 tokens as well as refresh them when they expire. This library uses Apps Script's new StateTokenBuilder and /usercallback endpoint to handle the redirects.

Setup

This library is already published as an Apps Script, making it easy to include in your project. To add it to your script, do the following in the Apps Script code editor:
  1. Click on the menu item "Resources > Libraries..."
  2. In the "Find a Library" text box, enter the script ID 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF and click the "Select" button.
  3. Choose a version in the dropdown box (usually best to pick the latest version).
  4. Click the "Save" button.
Alternatively, you can copy and paste the files in the /dist directory directly into your script project.

Github Google Samples: apps-script-oauth2/samples/Facebook.gs 


Deploying a script as a web app




Facebook 로그인 플로 직접 빌드

SDK를 사용하지 않고 앱의 브라우저 기반 로그인을 구현해야 하는 경우 브라우저 리디렉션을 사용하여 로그인 플로를 직접 빌드할 수 있습니다. 이 가이드에서는 로그인 플로의 각 단계를 설명하고 SDK를 사용하지 않고 각 단계를 구현하는 방법을 보여줍니다.


Facebook 로그인 - 유효한 OAuth 리디렉션 URI

Redirect URI
facebook apps developers fb-login -


Alternatively you can call the service's getRedirectUri() method to view the exact URL that the service will use when performing the OAuth flow:
  /**
   * Logs the redict URI to register.
   */
  function logRedirectUri() {
    var service = getService();
    Logger.log(service.getRedirectUri());
  }

function logRedirectUri() 실행 결과 로그 주소를 복사하여 붙여 넣습니다.



The application "OAuth2 for Apps Script - samples Facebook" needs authorization to run.


Google apps script with Facebook 로그인 실행 결과



There have been a couple of questions in my inbox around Blogger API access using Google Apps Script. The good news is Spencer Easton may be creating a client library for the Blogger API which might make things easier. Regardless of this an OAuth2 handshake may be may be required so here is a complete tutorial on using OAuth2 for Apps Script library to use the Blogger API.


댓글

이 블로그의 인기 게시물

Duplicate files, Deduper in Google Drive