5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

google api authorizeでの複数スコープ指定+α

Last updated at Posted at 2012-12-04

複数指定は出来るだろうと思っていたが
予想以上に情報が無かったので苦労の末ようやく実現できた。*参考元:本家

まさかSCOPEに指定する区切り文字が「 」(半角スペース)だったとは。。
カンマ、ピリオドとかは試したけど、これは思いつかなかった。

multiauth.js
    var scopesAry = $.map(scopeNames,function(v,idx){
        return "https://www.googleapis.com/auth/" + v;
    });
    var scopes = scopesAry.join(" ");

これでようやく、API使用準備がシンプルに出来るようになった(気がする)

useapi.js
//認証
helper.gapi.functions.authorize(["drive","calendar"]).done(function(res){
    var apis = [
      helper.gapi.functions.loadBy("drive","v2"),
      helper.gapi.functions.loadBy("calendar","v3")
    ];
    //成功後にAPIロード
    $.when.apply(null,apis).then(function(data){
       //使う
    }
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?