mirror of https://github.com/matrix-org/go-neb.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
507 lines
19 KiB
507 lines
19 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#375EAB">
|
|
|
|
<title>google - The Go Programming Language</title>
|
|
|
|
<link type="text/css" rel="stylesheet" href="../../../../../lib/godoc/style.css">
|
|
|
|
<link rel="stylesheet" href="../../../../../lib/godoc/jquery.treeview.css">
|
|
<script type="text/javascript">window.initFuncs = [];</script>
|
|
</head>
|
|
<body>
|
|
|
|
<div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
|
|
...
|
|
</div><!-- #lowframe -->
|
|
|
|
<div id="topbar" class="wide"><div class="container">
|
|
<div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
|
|
<div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
|
|
<a href="index.html#" id="menu-button"><span id="menu-button-arrow">▽</span></a>
|
|
<form method="GET" action="http://localhost:6060/search">
|
|
<div id="menu">
|
|
<a href="http://localhost:6060/doc/">Documents</a>
|
|
<a href="http://localhost:6060/pkg/">Packages</a>
|
|
<a href="http://localhost:6060/project/">The Project</a>
|
|
<a href="http://localhost:6060/help/">Help</a>
|
|
<a href="http://localhost:6060/blog/">Blog</a>
|
|
|
|
<input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
|
|
</div>
|
|
</form>
|
|
|
|
</div></div>
|
|
|
|
|
|
|
|
<div id="page" class="wide">
|
|
<div class="container">
|
|
|
|
|
|
<h1>Package google</h1>
|
|
|
|
|
|
|
|
|
|
<div id="nav"></div>
|
|
|
|
|
|
<!--
|
|
Copyright 2009 The Go Authors. All rights reserved.
|
|
Use of this source code is governed by a BSD-style
|
|
license that can be found in the LICENSE file.
|
|
-->
|
|
<!--
|
|
Note: Static (i.e., not template-generated) href and id
|
|
attributes start with "pkg-" to make it impossible for
|
|
them to conflict with generated attributes (some of which
|
|
correspond to Go identifiers).
|
|
-->
|
|
|
|
<script type='text/javascript'>
|
|
document.ANALYSIS_DATA = null;
|
|
document.CALLGRAPH = null;
|
|
</script>
|
|
|
|
|
|
|
|
<div id="short-nav">
|
|
<dl>
|
|
<dd><code>import "golang.org/x/oauth2/google"</code></dd>
|
|
</dl>
|
|
<dl>
|
|
<dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
|
|
<dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
|
|
|
|
|
|
</dl>
|
|
</div>
|
|
<!-- The package's Name is printed as title by the top-level template -->
|
|
<div id="pkg-overview" class="toggleVisible">
|
|
<div class="collapsed">
|
|
<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
|
|
</div>
|
|
<div class="expanded">
|
|
<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
|
|
<p>
|
|
Package google provides support for making OAuth2 authorized and
|
|
authenticated HTTP requests to Google APIs.
|
|
It supports the Web server flow, client-side credentials, service accounts,
|
|
Google Compute Engine service accounts, and Google App Engine service
|
|
accounts.
|
|
</p>
|
|
<p>
|
|
For more information, please read
|
|
<a href="https://developers.google.com/accounts/docs/OAuth2">https://developers.google.com/accounts/docs/OAuth2</a>
|
|
and
|
|
<a href="https://developers.google.com/accounts/docs/application-default-credentials">https://developers.google.com/accounts/docs/application-default-credentials</a>.
|
|
</p>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="pkg-index" class="toggleVisible">
|
|
<div class="collapsed">
|
|
<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
|
|
</div>
|
|
<div class="expanded">
|
|
<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
|
|
|
|
<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
|
|
<div id="manual-nav">
|
|
<dl>
|
|
|
|
<dd><a href="index.html#pkg-constants">Constants</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#pkg-variables">Variables</a></dd>
|
|
|
|
|
|
|
|
<dd><a href="index.html#AppEngineTokenSource">func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#ComputeTokenSource">func ComputeTokenSource(account string) oauth2.TokenSource</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#ConfigFromJSON">func ConfigFromJSON(jsonKey []byte, scope ...string) (*oauth2.Config, error)</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#DefaultClient">func DefaultClient(ctx context.Context, scope ...string) (*http.Client, error)</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#DefaultTokenSource">func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSource, error)</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#JWTAccessTokenSourceFromJSON">func JWTAccessTokenSourceFromJSON(jsonKey []byte, audience string) (oauth2.TokenSource, error)</a></dd>
|
|
|
|
|
|
<dd><a href="index.html#JWTConfigFromJSON">func JWTConfigFromJSON(jsonKey []byte, scope ...string) (*jwt.Config, error)</a></dd>
|
|
|
|
|
|
|
|
<dd><a href="index.html#SDKConfig">type SDKConfig</a></dd>
|
|
|
|
|
|
<dd> <a href="index.html#NewSDKConfig">func NewSDKConfig(account string) (*SDKConfig, error)</a></dd>
|
|
|
|
|
|
|
|
<dd> <a href="index.html#SDKConfig.Client">func (c *SDKConfig) Client(ctx context.Context) *http.Client</a></dd>
|
|
|
|
|
|
<dd> <a href="index.html#SDKConfig.Scopes">func (c *SDKConfig) Scopes() []string</a></dd>
|
|
|
|
|
|
<dd> <a href="index.html#SDKConfig.TokenSource">func (c *SDKConfig) TokenSource(ctx context.Context) oauth2.TokenSource</a></dd>
|
|
|
|
|
|
|
|
</dl>
|
|
</div><!-- #manual-nav -->
|
|
|
|
|
|
|
|
|
|
<h4>Package files</h4>
|
|
<p>
|
|
<span style="font-size:90%">
|
|
|
|
<a href="http://localhost:6060/src/golang.org/x/oauth2/google/appengine.go">appengine.go</a>
|
|
|
|
<a href="http://localhost:6060/src/golang.org/x/oauth2/google/default.go">default.go</a>
|
|
|
|
<a href="http://localhost:6060/src/golang.org/x/oauth2/google/google.go">google.go</a>
|
|
|
|
<a href="http://localhost:6060/src/golang.org/x/oauth2/google/jwt.go">jwt.go</a>
|
|
|
|
<a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go">sdk.go</a>
|
|
|
|
</span>
|
|
</p>
|
|
|
|
</div><!-- .expanded -->
|
|
</div><!-- #pkg-index -->
|
|
|
|
<div id="pkg-callgraph" class="toggle" style="display: none">
|
|
<div class="collapsed">
|
|
<h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
|
|
</div> <!-- .expanded -->
|
|
<div class="expanded">
|
|
<h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
|
|
<p>
|
|
In the call graph viewer below, each node
|
|
is a function belonging to this package
|
|
and its children are the functions it
|
|
calls—perhaps dynamically.
|
|
</p>
|
|
<p>
|
|
The root nodes are the entry points of the
|
|
package: functions that may be called from
|
|
outside the package.
|
|
There may be non-exported or anonymous
|
|
functions among them if they are called
|
|
dynamically from another package.
|
|
</p>
|
|
<p>
|
|
Click a node to visit that function's source code.
|
|
From there you can visit its callers by
|
|
clicking its declaring <code>func</code>
|
|
token.
|
|
</p>
|
|
<p>
|
|
Functions may be omitted if they were
|
|
determined to be unreachable in the
|
|
particular programs or tests that were
|
|
analyzed.
|
|
</p>
|
|
<!-- Zero means show all package entry points. -->
|
|
<ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
|
|
</div>
|
|
</div> <!-- #pkg-callgraph -->
|
|
|
|
|
|
<h2 id="pkg-constants">Constants</h2>
|
|
|
|
<pre>const <span id="JWTTokenURL">JWTTokenURL</span> = "https://accounts.google.com/o/oauth2/token"</pre>
|
|
<p>
|
|
JWTTokenURL is Google's OAuth 2.0 token URL to use with the JWT flow.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<h2 id="pkg-variables">Variables</h2>
|
|
|
|
<pre>var <span id="Endpoint">Endpoint</span> = <a href="../index.html">oauth2</a>.<a href="../index.html#Endpoint">Endpoint</a>{
|
|
<a href="index.html#AuthURL">AuthURL</a>: "https://accounts.google.com/o/oauth2/auth",
|
|
<a href="index.html#TokenURL">TokenURL</a>: "https://accounts.google.com/o/oauth2/token",
|
|
}</pre>
|
|
<p>
|
|
Endpoint is Google's OAuth 2.0 endpoint.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="AppEngineTokenSource">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/appengine.go?s=898:980#L19">AppEngineTokenSource</a></h2>
|
|
<pre>func AppEngineTokenSource(ctx <a href="../../net/context/index.html">context</a>.<a href="../../net/context/index.html#Context">Context</a>, scope ...<a href="../../../../builtin/index.html#string">string</a>) <a href="../index.html">oauth2</a>.<a href="../index.html#TokenSource">TokenSource</a></pre>
|
|
<p>
|
|
AppEngineTokenSource returns a token source that fetches tokens
|
|
issued to the current App Engine application's service account.
|
|
If you are implementing a 3-legged OAuth 2.0 flow on App Engine
|
|
that involves user accounts, see oauth2.Config instead.
|
|
</p>
|
|
<p>
|
|
The provided context must have come from appengine.NewContext.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="ComputeTokenSource">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/google.go?s=3745:3803#L102">ComputeTokenSource</a></h2>
|
|
<pre>func ComputeTokenSource(account <a href="../../../../builtin/index.html#string">string</a>) <a href="../index.html">oauth2</a>.<a href="../index.html#TokenSource">TokenSource</a></pre>
|
|
<p>
|
|
ComputeTokenSource returns a token source that fetches access tokens
|
|
from Google Compute Engine (GCE)'s metadata server. It's only valid to use
|
|
this token source if your program is running on a GCE instance.
|
|
If no account is specified, "default" is used.
|
|
Further information about retrieving access tokens from the GCE metadata
|
|
server can be found at <a href="https://cloud.google.com/compute/docs/authentication">https://cloud.google.com/compute/docs/authentication</a>.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="ConfigFromJSON">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/google.go?s=1501:1577#L34">ConfigFromJSON</a></h2>
|
|
<pre>func ConfigFromJSON(jsonKey []<a href="../../../../builtin/index.html#byte">byte</a>, scope ...<a href="../../../../builtin/index.html#string">string</a>) (*<a href="../index.html">oauth2</a>.<a href="../index.html#Config">Config</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
ConfigFromJSON uses a Google Developers Console client_credentials.json
|
|
file to construct a config.
|
|
client_credentials.json can be downloaded from
|
|
<a href="https://console.developers.google.com">https://console.developers.google.com</a>, under "Credentials". Download the Web
|
|
application credentials in the JSON format and provide the contents of the
|
|
file as jsonKey.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="DefaultClient">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/default.go?s=791:869#L23">DefaultClient</a></h2>
|
|
<pre>func DefaultClient(ctx <a href="../../net/context/index.html">context</a>.<a href="../../net/context/index.html#Context">Context</a>, scope ...<a href="../../../../builtin/index.html#string">string</a>) (*<a href="../../../../net/http/index.html">http</a>.<a href="../../../../net/http/index.html#Client">Client</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
DefaultClient returns an HTTP Client that uses the
|
|
DefaultTokenSource to obtain authentication credentials.
|
|
</p>
|
|
<p>
|
|
This client should be used when developing services
|
|
that run on Google App Engine or Google Compute Engine
|
|
and use "Application Default Credentials."
|
|
</p>
|
|
<p>
|
|
For more details, see:
|
|
<a href="https://developers.google.com/accounts/docs/application-default-credentials">https://developers.google.com/accounts/docs/application-default-credentials</a>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="DefaultTokenSource">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/default.go?s=1909:1998#L50">DefaultTokenSource</a></h2>
|
|
<pre>func DefaultTokenSource(ctx <a href="../../net/context/index.html">context</a>.<a href="../../net/context/index.html#Context">Context</a>, scope ...<a href="../../../../builtin/index.html#string">string</a>) (<a href="../index.html">oauth2</a>.<a href="../index.html#TokenSource">TokenSource</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
DefaultTokenSource is a token source that uses
|
|
"Application Default Credentials".
|
|
</p>
|
|
<p>
|
|
It looks for credentials in the following places,
|
|
preferring the first location found:
|
|
</p>
|
|
<pre>1. A JSON file whose path is specified by the
|
|
GOOGLE_APPLICATION_CREDENTIALS environment variable.
|
|
2. A JSON file in a location known to the gcloud command-line tool.
|
|
On Windows, this is %APPDATA%/gcloud/application_default_credentials.json.
|
|
On other systems, $HOME/.config/gcloud/application_default_credentials.json.
|
|
3. On Google App Engine it uses the appengine.AccessToken function.
|
|
4. On Google Compute Engine and Google App Engine Managed VMs, it fetches
|
|
credentials from the metadata server.
|
|
(In this final case any provided scopes are ignored.)
|
|
</pre>
|
|
<p>
|
|
For more details, see:
|
|
<a href="https://developers.google.com/accounts/docs/application-default-credentials">https://developers.google.com/accounts/docs/application-default-credentials</a>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="JWTAccessTokenSourceFromJSON">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/jwt.go?s=857:951#L16">JWTAccessTokenSourceFromJSON</a></h2>
|
|
<pre>func JWTAccessTokenSourceFromJSON(jsonKey []<a href="../../../../builtin/index.html#byte">byte</a>, audience <a href="../../../../builtin/index.html#string">string</a>) (<a href="../index.html">oauth2</a>.<a href="../index.html#TokenSource">TokenSource</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
JWTAccessTokenSourceFromJSON uses a Google Developers service account JSON
|
|
key file to read the credentials that authorize and authenticate the
|
|
requests, and returns a TokenSource that does not use any OAuth2 flow but
|
|
instead creates a JWT and sends that as the access token.
|
|
The audience is typically a URL that specifies the scope of the credentials.
|
|
</p>
|
|
<p>
|
|
Note that this is not a standard OAuth flow, but rather an
|
|
optimization supported by a few Google services.
|
|
Unless you know otherwise, you should use JWTConfigFromJSON instead.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="JWTConfigFromJSON">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/google.go?s=2810:2886#L77">JWTConfigFromJSON</a></h2>
|
|
<pre>func JWTConfigFromJSON(jsonKey []<a href="../../../../builtin/index.html#byte">byte</a>, scope ...<a href="../../../../builtin/index.html#string">string</a>) (*<a href="../jwt/index.html">jwt</a>.<a href="../jwt/index.html#Config">Config</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
JWTConfigFromJSON uses a Google Developers service account JSON key file to read
|
|
the credentials that authorize and authenticate the requests.
|
|
Create a service account on "Credentials" for your project at
|
|
<a href="https://console.developers.google.com">https://console.developers.google.com</a> to download a JSON key file.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="SDKConfig">type <a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go?s=930:1011#L32">SDKConfig</a></h2>
|
|
<pre>type SDKConfig struct {
|
|
<span class="comment">// contains filtered or unexported fields</span>
|
|
}</pre>
|
|
<p>
|
|
An SDKConfig provides access to tokens from an account already
|
|
authorized via the Google Cloud SDK.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="NewSDKConfig">func <a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go?s=1361:1414#L43">NewSDKConfig</a></h3>
|
|
<pre>func NewSDKConfig(account <a href="../../../../builtin/index.html#string">string</a>) (*<a href="index.html#SDKConfig">SDKConfig</a>, <a href="../../../../builtin/index.html#error">error</a>)</pre>
|
|
<p>
|
|
NewSDKConfig creates an SDKConfig for the given Google Cloud SDK
|
|
account. If account is empty, the account currently active in
|
|
Google Cloud SDK properties is used.
|
|
Google Cloud SDK credentials must be created by running `gcloud auth`
|
|
before using this function.
|
|
The Google Cloud SDK is available at <a href="https://cloud.google.com/sdk/">https://cloud.google.com/sdk/</a>.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="SDKConfig.Client">func (*SDKConfig) <a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go?s=3955:4015#L117">Client</a></h3>
|
|
<pre>func (c *<a href="index.html#SDKConfig">SDKConfig</a>) Client(ctx <a href="../../net/context/index.html">context</a>.<a href="../../net/context/index.html#Context">Context</a>) *<a href="../../../../net/http/index.html">http</a>.<a href="../../../../net/http/index.html#Client">Client</a></pre>
|
|
<p>
|
|
Client returns an HTTP client using Google Cloud SDK credentials to
|
|
authorize requests. The token will auto-refresh as necessary. The
|
|
underlying http.RoundTripper will be obtained using the provided
|
|
context. The returned client and its Transport should not be
|
|
modified.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="SDKConfig.Scopes">func (*SDKConfig) <a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go?s=4616:4653#L135">Scopes</a></h3>
|
|
<pre>func (c *<a href="index.html#SDKConfig">SDKConfig</a>) Scopes() []<a href="../../../../builtin/index.html#string">string</a></pre>
|
|
<p>
|
|
Scopes are the OAuth 2.0 scopes the current account is authorized for.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="SDKConfig.TokenSource">func (*SDKConfig) <a href="http://localhost:6060/src/golang.org/x/oauth2/google/sdk.go?s=4417:4488#L130">TokenSource</a></h3>
|
|
<pre>func (c *<a href="index.html#SDKConfig">SDKConfig</a>) TokenSource(ctx <a href="../../net/context/index.html">context</a>.<a href="../../net/context/index.html#Context">Context</a>) <a href="../index.html">oauth2</a>.<a href="../index.html#TokenSource">TokenSource</a></pre>
|
|
<p>
|
|
TokenSource returns an oauth2.TokenSource that retrieve tokens from
|
|
Google Cloud SDK credentials using the provided context.
|
|
It will returns the current access token stored in the credentials,
|
|
and refresh it when it expires, but it won't update the credentials
|
|
with the new access token.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div id="footer">
|
|
Build version go1.6.<br>
|
|
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
|
|
the content of this page is licensed under the
|
|
Creative Commons Attribution 3.0 License,
|
|
and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
|
|
<a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
|
|
<a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
|
|
</div>
|
|
|
|
</div><!-- .container -->
|
|
</div><!-- #page -->
|
|
|
|
<!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
|
|
<script type="text/javascript" src="../../../../../lib/godoc/jquery.js"></script>
|
|
<script type="text/javascript" src="../../../../../lib/godoc/jquery.treeview.js"></script>
|
|
<script type="text/javascript" src="../../../../../lib/godoc/jquery.treeview.edit.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../../../../lib/godoc/godocs.js"></script>
|
|
|
|
</body>
|
|
</html>
|
|
|