...

Source file src/golang.org/x/oauth2/google/appengine.go

Documentation: golang.org/x/oauth2/google

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package google
     6  
     7  import (
     8  	"context"
     9  	"log"
    10  	"sync"
    11  
    12  	"golang.org/x/oauth2"
    13  )
    14  
    15  var logOnce sync.Once // only spam about deprecation once
    16  
    17  // AppEngineTokenSource returns a token source that fetches tokens from either
    18  // the current application's service account or from the metadata server,
    19  // depending on the App Engine environment. See below for environment-specific
    20  // details. If you are implementing a 3-legged OAuth 2.0 flow on App Engine that
    21  // involves user accounts, see oauth2.Config instead.
    22  //
    23  // The current version of this library requires at least Go 1.17 to build,
    24  // so first generation App Engine runtimes (<= Go 1.9) are unsupported.
    25  // Previously, on first generation App Engine runtimes, AppEngineTokenSource
    26  // returned a token source that fetches tokens issued to the
    27  // current App Engine application's service account. The provided context must have
    28  // come from appengine.NewContext.
    29  //
    30  // Second generation App Engine runtimes (>= Go 1.11) and App Engine flexible:
    31  // AppEngineTokenSource is DEPRECATED on second generation runtimes and on the
    32  // flexible environment. It delegates to ComputeTokenSource, and the provided
    33  // context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource,
    34  // which DefaultTokenSource will use in this case) instead.
    35  func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
    36  	logOnce.Do(func() {
    37  		log.Print("google: AppEngineTokenSource is deprecated on App Engine standard second generation runtimes (>= Go 1.11) and App Engine flexible. Please use DefaultTokenSource or ComputeTokenSource.")
    38  	})
    39  	return ComputeTokenSource("")
    40  }
    41  

View as plain text