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.

902 lines
28 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>oauth1 - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package oauth1</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "github.com/dghubble/oauth1"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-subdirectories">Subdirectories</a></dd>
  58. </dl>
  59. </div>
  60. <!-- The package's Name is printed as title by the top-level template -->
  61. <div id="pkg-overview" class="toggleVisible">
  62. <div class="collapsed">
  63. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  64. </div>
  65. <div class="expanded">
  66. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  67. <p>
  68. Package oauth1 is a Go implementation of the OAuth1 spec RFC 5849.
  69. </p>
  70. <p>
  71. It allows end-users to authorize a client (consumer) to access protected
  72. resources on their behalf (e.g. login) and allows clients to make signed and
  73. authorized requests on behalf of a user (e.g. API calls).
  74. </p>
  75. <p>
  76. It takes design cues from golang.org/x/oauth2, providing an http.Client which
  77. handles request signing and authorization.
  78. </p>
  79. <h3 id="hdr-Usage">Usage</h3>
  80. <p>
  81. Package oauth1 implements the OAuth1 authorization flow and provides an
  82. http.Client which can sign and authorize OAuth1 requests.
  83. </p>
  84. <p>
  85. To implement &#34;Login with X&#34;, use the <a href="https://github.com/dghubble/gologin">https://github.com/dghubble/gologin</a>
  86. packages which provide login handlers for OAuth1 and OAuth2 providers.
  87. </p>
  88. <p>
  89. To call the Twitter, Digits, or Tumblr OAuth1 APIs, use the higher level Go API
  90. clients.
  91. </p>
  92. <p>
  93. * <a href="https://github.com/dghubble/go-twitter">https://github.com/dghubble/go-twitter</a>
  94. * <a href="https://github.com/dghubble/go-digits">https://github.com/dghubble/go-digits</a>
  95. * <a href="https://github.com/benfb/go-tumblr">https://github.com/benfb/go-tumblr</a>
  96. </p>
  97. <h3 id="hdr-Authorization_Flow">Authorization Flow</h3>
  98. <p>
  99. Perform the OAuth 1 authorization flow to ask a user to grant an application
  100. access to his/her resources via an access token.
  101. </p>
  102. <pre>import (
  103. &#34;github.com/dghubble/oauth1&#34;
  104. &#34;github.com/dghubble/oauth1/twitter&#34;&#34;
  105. )
  106. ...
  107. config := oauth1.Config{
  108. ConsumerKey: &#34;consumerKey&#34;,
  109. ConsumerSecret: &#34;consumerSecret&#34;,
  110. CallbackURL: &#34;<a href="http://mysite.com/oauth/twitter/callback">http://mysite.com/oauth/twitter/callback</a>&#34;,
  111. Endpoint: twitter.AuthorizeEndpoint,
  112. }
  113. </pre>
  114. <p>
  115. 1. When a user performs an action (e.g. &#34;Login with X&#34; button calls &#34;/login&#34;
  116. route) get an OAuth1 request token (temporary credentials).
  117. </p>
  118. <pre>requestToken, requestSecret, err = config.RequestToken()
  119. // handle err
  120. </pre>
  121. <p>
  122. 2. Obtain authorization from the user by redirecting them to the OAuth1
  123. provider&#39;s authorization URL to grant the application access.
  124. </p>
  125. <pre>authorizationURL, err := config.AuthorizationURL(requestToken)
  126. // handle err
  127. http.Redirect(w, req, authorizationURL.String(), htt.StatusFound)
  128. </pre>
  129. <p>
  130. Receive the callback from the OAuth1 provider in a handler.
  131. </p>
  132. <pre>requestToken, verifier, err := oauth1.ParseAuthorizationCallback(req)
  133. // handle err
  134. </pre>
  135. <p>
  136. 3. Acquire the access token (token credentials) which can later be used
  137. to make requests on behalf of the user.
  138. </p>
  139. <pre>accessToken, accessSecret, err := config.AccessToken(requestToken, requestSecret, verifier)
  140. // handle error
  141. token := NewToken(accessToken, accessSecret)
  142. </pre>
  143. <p>
  144. Check the examples to see this authorization flow in action from the command
  145. line, with Twitter PIN-based login and Tumblr login.
  146. </p>
  147. <h3 id="hdr-Authorized_Requests">Authorized Requests</h3>
  148. <p>
  149. Use an access Token to make authorized requests on behalf of a user.
  150. </p>
  151. <pre>import (
  152. &#34;github.com/dghubble/oauth1&#34;
  153. )
  154. func main() {
  155. config := oauth1.NewConfig(&#34;consumerKey&#34;, &#34;consumerSecret&#34;)
  156. token := oauth1.NewToken(&#34;token&#34;, &#34;tokenSecret&#34;)
  157. // httpClient will automatically authorize http.Request&#39;s
  158. httpClient := config.Client(token)
  159. // example Twitter API request
  160. path := &#34;<a href="https://api.twitter.com/1.1/statuses/home_timeline.json?count=2">https://api.twitter.com/1.1/statuses/home_timeline.json?count=2</a>&#34;
  161. resp, _ := httpClient.Get(path)
  162. defer resp.Body.Close()
  163. body, _ := ioutil.ReadAll(resp.Body)
  164. fmt.Printf(&#34;Raw Response Body:\n%v\n&#34;, string(body))
  165. }
  166. </pre>
  167. <p>
  168. Check the examples to see Twitter and Tumblr requests in action.
  169. </p>
  170. </div>
  171. </div>
  172. <div id="pkg-index" class="toggleVisible">
  173. <div class="collapsed">
  174. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  175. </div>
  176. <div class="expanded">
  177. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  178. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  179. <div id="manual-nav">
  180. <dl>
  181. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  182. <dd><a href="index.html#NewClient">func NewClient(ctx context.Context, config *Config, token *Token) *http.Client</a></dd>
  183. <dd><a href="index.html#ParseAuthorizationCallback">func ParseAuthorizationCallback(req *http.Request) (requestToken, verifier string, err error)</a></dd>
  184. <dd><a href="index.html#PercentEncode">func PercentEncode(input string) string</a></dd>
  185. <dd><a href="index.html#Config">type Config</a></dd>
  186. <dd>&nbsp; &nbsp; <a href="index.html#NewConfig">func NewConfig(consumerKey, consumerSecret string) *Config</a></dd>
  187. <dd>&nbsp; &nbsp; <a href="index.html#Config.AccessToken">func (c *Config) AccessToken(requestToken, requestSecret, verifier string) (accessToken, accessSecret string, err error)</a></dd>
  188. <dd>&nbsp; &nbsp; <a href="index.html#Config.AuthorizationURL">func (c *Config) AuthorizationURL(requestToken string) (*url.URL, error)</a></dd>
  189. <dd>&nbsp; &nbsp; <a href="index.html#Config.Client">func (c *Config) Client(ctx context.Context, t *Token) *http.Client</a></dd>
  190. <dd>&nbsp; &nbsp; <a href="index.html#Config.RequestToken">func (c *Config) RequestToken() (requestToken, requestSecret string, err error)</a></dd>
  191. <dd><a href="index.html#Endpoint">type Endpoint</a></dd>
  192. <dd><a href="index.html#HMACSigner">type HMACSigner</a></dd>
  193. <dd>&nbsp; &nbsp; <a href="index.html#HMACSigner.Name">func (s *HMACSigner) Name() string</a></dd>
  194. <dd>&nbsp; &nbsp; <a href="index.html#HMACSigner.Sign">func (s *HMACSigner) Sign(tokenSecret, message string) (string, error)</a></dd>
  195. <dd><a href="index.html#RSASigner">type RSASigner</a></dd>
  196. <dd>&nbsp; &nbsp; <a href="index.html#RSASigner.Name">func (s *RSASigner) Name() string</a></dd>
  197. <dd>&nbsp; &nbsp; <a href="index.html#RSASigner.Sign">func (s *RSASigner) Sign(tokenSecret, message string) (string, error)</a></dd>
  198. <dd><a href="index.html#Signer">type Signer</a></dd>
  199. <dd><a href="index.html#Token">type Token</a></dd>
  200. <dd>&nbsp; &nbsp; <a href="index.html#NewToken">func NewToken(token, tokenSecret string) *Token</a></dd>
  201. <dd><a href="index.html#TokenSource">type TokenSource</a></dd>
  202. <dd>&nbsp; &nbsp; <a href="index.html#StaticTokenSource">func StaticTokenSource(token *Token) TokenSource</a></dd>
  203. <dd><a href="index.html#Transport">type Transport</a></dd>
  204. <dd>&nbsp; &nbsp; <a href="index.html#Transport.RoundTrip">func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)</a></dd>
  205. </dl>
  206. </div><!-- #manual-nav -->
  207. <h4>Package files</h4>
  208. <p>
  209. <span style="font-size:90%">
  210. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/auther.go">auther.go</a>
  211. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go">config.go</a>
  212. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/context.go">context.go</a>
  213. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/doc.go">doc.go</a>
  214. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/encode.go">encode.go</a>
  215. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/endpoint.go">endpoint.go</a>
  216. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go">signer.go</a>
  217. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/token.go">token.go</a>
  218. <a href="http://localhost:6060/src/github.com/dghubble/oauth1/transport.go">transport.go</a>
  219. </span>
  220. </p>
  221. </div><!-- .expanded -->
  222. </div><!-- #pkg-index -->
  223. <div id="pkg-callgraph" class="toggle" style="display: none">
  224. <div class="collapsed">
  225. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  226. </div> <!-- .expanded -->
  227. <div class="expanded">
  228. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  229. <p>
  230. In the call graph viewer below, each node
  231. is a function belonging to this package
  232. and its children are the functions it
  233. calls&mdash;perhaps dynamically.
  234. </p>
  235. <p>
  236. The root nodes are the entry points of the
  237. package: functions that may be called from
  238. outside the package.
  239. There may be non-exported or anonymous
  240. functions among them if they are called
  241. dynamically from another package.
  242. </p>
  243. <p>
  244. Click a node to visit that function's source code.
  245. From there you can visit its callers by
  246. clicking its declaring <code>func</code>
  247. token.
  248. </p>
  249. <p>
  250. Functions may be omitted if they were
  251. determined to be unreachable in the
  252. particular programs or tests that were
  253. analyzed.
  254. </p>
  255. <!-- Zero means show all package entry points. -->
  256. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  257. </div>
  258. </div> <!-- #pkg-callgraph -->
  259. <h2 id="pkg-variables">Variables</h2>
  260. <pre>var <span id="HTTPClient">HTTPClient</span> contextKey</pre>
  261. <p>
  262. HTTPClient is the context key to associate an *http.Client value with
  263. a context.
  264. </p>
  265. <pre>var <span id="NoContext">NoContext</span> = <a href="../../../golang.org/x/net/context/index.html">context</a>.<a href="../../../golang.org/x/net/context/index.html#TODO">TODO</a>()</pre>
  266. <p>
  267. NoContext is the default context to use in most cases.
  268. </p>
  269. <h2 id="NewClient">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=1165:1243#L36">NewClient</a></h2>
  270. <pre>func NewClient(ctx <a href="../../../golang.org/x/net/context/index.html">context</a>.<a href="../../../golang.org/x/net/context/index.html#Context">Context</a>, config *<a href="index.html#Config">Config</a>, token *<a href="index.html#Token">Token</a>) *<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Client">Client</a></pre>
  271. <p>
  272. NewClient returns a new http Client which signs requests via OAuth1.
  273. </p>
  274. <h2 id="ParseAuthorizationCallback">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=3797:3890#L106">ParseAuthorizationCallback</a></h2>
  275. <pre>func ParseAuthorizationCallback(req *<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Request">Request</a>) (requestToken, verifier <a href="../../../builtin/index.html#string">string</a>, err <a href="../../../builtin/index.html#error">error</a>)</pre>
  276. <p>
  277. ParseAuthorizationCallback parses an OAuth1 authorization callback request
  278. from a provider server. The oauth_token and oauth_verifier parameters are
  279. parsed to return the request token from earlier in the flow and the
  280. verifier string.
  281. See RFC 5849 2.2 Resource Owner Authorization.
  282. </p>
  283. <h2 id="PercentEncode">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/encode.go?s=113:152#L1">PercentEncode</a></h2>
  284. <pre>func PercentEncode(input <a href="../../../builtin/index.html#string">string</a>) <a href="../../../builtin/index.html#string">string</a></pre>
  285. <p>
  286. PercentEncode percent encodes a string according to RFC 3986 2.1.
  287. </p>
  288. <h2 id="Config">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=375:687#L9">Config</a></h2>
  289. <pre>type Config struct {
  290. <span class="comment">// Consumer Key (Client Identifier)</span>
  291. ConsumerKey <a href="../../../builtin/index.html#string">string</a>
  292. <span class="comment">// Consumer Secret (Client Shared-Secret)</span>
  293. ConsumerSecret <a href="../../../builtin/index.html#string">string</a>
  294. <span class="comment">// Callback URL</span>
  295. CallbackURL <a href="../../../builtin/index.html#string">string</a>
  296. <span class="comment">// Provider Endpoint specifying OAuth1 endpoint URLs</span>
  297. Endpoint <a href="index.html#Endpoint">Endpoint</a>
  298. <span class="comment">// OAuth1 Signer (defaults to HMAC-SHA1)</span>
  299. Signer <a href="index.html#Signer">Signer</a>
  300. }</pre>
  301. <p>
  302. Config represents an OAuth1 consumer&#39;s (client&#39;s) key and secret, the
  303. callback URL, and the provider Endpoint to which the consumer corresponds.
  304. </p>
  305. <h3 id="NewConfig">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=763:821#L23">NewConfig</a></h3>
  306. <pre>func NewConfig(consumerKey, consumerSecret <a href="../../../builtin/index.html#string">string</a>) *<a href="index.html#Config">Config</a></pre>
  307. <p>
  308. NewConfig returns a new Config with the given consumer key and secret.
  309. </p>
  310. <h3 id="Config.AccessToken">func (*Config) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=4542:4662#L125">AccessToken</a></h3>
  311. <pre>func (c *<a href="index.html#Config">Config</a>) AccessToken(requestToken, requestSecret, verifier <a href="../../../builtin/index.html#string">string</a>) (accessToken, accessSecret <a href="../../../builtin/index.html#string">string</a>, err <a href="../../../builtin/index.html#error">error</a>)</pre>
  312. <p>
  313. AccessToken obtains an access token (token credential) by POSTing a
  314. request (with oauth_token and oauth_verifier in the auth header) to the
  315. Endpoint AccessTokenURL. Returns the access token and secret (token
  316. credentials).
  317. See RFC 5849 2.3 Token Credentials.
  318. </p>
  319. <h3 id="Config.AuthorizationURL">func (*Config) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=3170:3242#L90">AuthorizationURL</a></h3>
  320. <pre>func (c *<a href="index.html#Config">Config</a>) AuthorizationURL(requestToken <a href="../../../builtin/index.html#string">string</a>) (*<a href="../../../net/url/index.html">url</a>.<a href="../../../net/url/index.html#URL">URL</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  321. <p>
  322. AuthorizationURL accepts a request token and returns the *url.URL to the
  323. Endpoint&#39;s authorization page that asks the user (resource owner) for to
  324. authorize the consumer to act on his/her/its behalf.
  325. See RFC 5849 2.2 Resource Owner Authorization.
  326. </p>
  327. <h3 id="Config.Client">func (*Config) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=991:1058#L31">Client</a></h3>
  328. <pre>func (c *<a href="index.html#Config">Config</a>) Client(ctx <a href="../../../golang.org/x/net/context/index.html">context</a>.<a href="../../../golang.org/x/net/context/index.html#Context">Context</a>, t *<a href="index.html#Token">Token</a>) *<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Client">Client</a></pre>
  329. <p>
  330. Client returns an HTTP client which uses the provided ctx and access Token.
  331. </p>
  332. <h3 id="Config.RequestToken">func (*Config) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/config.go?s=1785:1864#L51">RequestToken</a></h3>
  333. <pre>func (c *<a href="index.html#Config">Config</a>) RequestToken() (requestToken, requestSecret <a href="../../../builtin/index.html#string">string</a>, err <a href="../../../builtin/index.html#error">error</a>)</pre>
  334. <p>
  335. RequestToken obtains a Request token and secret (temporary credential) by
  336. POSTing a request (with oauth_callback in the auth header) to the Endpoint
  337. RequestTokenURL. The response body form is validated to ensure
  338. oauth_callback_confirmed is true. Returns the request token and secret
  339. (temporary credentials).
  340. See RFC 5849 2.1 Temporary Credentials.
  341. </p>
  342. <h2 id="Endpoint">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/endpoint.go?s=141:378#L1">Endpoint</a></h2>
  343. <pre>type Endpoint struct {
  344. <span class="comment">// Request URL (Temporary Credential Request URI)</span>
  345. RequestTokenURL <a href="../../../builtin/index.html#string">string</a>
  346. <span class="comment">// Authorize URL (Resource Owner Authorization URI)</span>
  347. AuthorizeURL <a href="../../../builtin/index.html#string">string</a>
  348. <span class="comment">// Access Token URL (Token Request URI)</span>
  349. AccessTokenURL <a href="../../../builtin/index.html#string">string</a>
  350. }</pre>
  351. <p>
  352. Endpoint represents an OAuth1 provider&#39;s (server&#39;s) request token,
  353. owner authorization, and access token request URLs.
  354. </p>
  355. <h2 id="HMACSigner">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=510:559#L13">HMACSigner</a></h2>
  356. <pre>type HMACSigner struct {
  357. ConsumerSecret <a href="../../../builtin/index.html#string">string</a>
  358. }</pre>
  359. <p>
  360. HMACSigner signs messages with an HMAC SHA1 digest, using the concatenated
  361. consumer secret and token secret as the key.
  362. </p>
  363. <h3 id="HMACSigner.Name">func (*HMACSigner) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=599:633#L18">Name</a></h3>
  364. <pre>func (s *<a href="index.html#HMACSigner">HMACSigner</a>) Name() <a href="../../../builtin/index.html#string">string</a></pre>
  365. <p>
  366. Name returns the HMAC-SHA1 method.
  367. </p>
  368. <h3 id="HMACSigner.Sign">func (*HMACSigner) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=811:881#L24">Sign</a></h3>
  369. <pre>func (s *<a href="index.html#HMACSigner">HMACSigner</a>) Sign(tokenSecret, message <a href="../../../builtin/index.html#string">string</a>) (<a href="../../../builtin/index.html#string">string</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  370. <p>
  371. Sign creates a concatenated consumer and token secret key and calculates
  372. the HMAC digest of the message. Returns the base64 encoded digest bytes.
  373. </p>
  374. <h2 id="RSASigner">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=1226:1279#L34">RSASigner</a></h2>
  375. <pre>type RSASigner struct {
  376. PrivateKey *<a href="../../../crypto/rsa/index.html">rsa</a>.<a href="../../../crypto/rsa/index.html#PrivateKey">PrivateKey</a>
  377. }</pre>
  378. <p>
  379. RSASigner RSA PKCS1-v1_5 signs SHA1 digests of messages using the given
  380. RSA private key.
  381. </p>
  382. <h3 id="RSASigner.Name">func (*RSASigner) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=1318:1351#L39">Name</a></h3>
  383. <pre>func (s *<a href="index.html#RSASigner">RSASigner</a>) Name() <a href="../../../builtin/index.html#string">string</a></pre>
  384. <p>
  385. Name returns the RSA-SHA1 method.
  386. </p>
  387. <h3 id="RSASigner.Sign">func (*RSASigner) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=1505:1574#L45">Sign</a></h3>
  388. <pre>func (s *<a href="index.html#RSASigner">RSASigner</a>) Sign(tokenSecret, message <a href="../../../builtin/index.html#string">string</a>) (<a href="../../../builtin/index.html#string">string</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  389. <p>
  390. Sign uses RSA PKCS1-v1_5 to sign a SHA1 digest of the given message. The
  391. tokenSecret is not used with this signing scheme.
  392. </p>
  393. <h2 id="Signer">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/signer.go?s=188:382#L4">Signer</a></h2>
  394. <pre>type Signer interface {
  395. <span class="comment">// Name returns the name of the signing method.</span>
  396. Name() <a href="../../../builtin/index.html#string">string</a>
  397. <span class="comment">// Sign signs the message using the given secret key.</span>
  398. Sign(key <a href="../../../builtin/index.html#string">string</a>, message <a href="../../../builtin/index.html#string">string</a>) (<a href="../../../builtin/index.html#string">string</a>, <a href="../../../builtin/index.html#error">error</a>)
  399. }</pre>
  400. <p>
  401. A Signer signs messages to create signed OAuth1 Requests.
  402. </p>
  403. <h2 id="Token">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/token.go?s=266:327#L4">Token</a></h2>
  404. <pre>type Token struct {
  405. Token <a href="../../../builtin/index.html#string">string</a>
  406. TokenSecret <a href="../../../builtin/index.html#string">string</a>
  407. }</pre>
  408. <p>
  409. Token is an AccessToken (token credential) which allows a consumer (client)
  410. to access resources from an OAuth1 provider server.
  411. </p>
  412. <h3 id="NewToken">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/token.go?s=400:447#L10">NewToken</a></h3>
  413. <pre>func NewToken(token, tokenSecret <a href="../../../builtin/index.html#string">string</a>) *<a href="index.html#Token">Token</a></pre>
  414. <p>
  415. NewToken returns a new Token with the given token and token secret.
  416. </p>
  417. <h2 id="TokenSource">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/token.go?s=75:130#L1">TokenSource</a></h2>
  418. <pre>type TokenSource interface {
  419. Token() (*<a href="index.html#Token">Token</a>, <a href="../../../builtin/index.html#error">error</a>)
  420. }</pre>
  421. <p>
  422. A TokenSource can return a Token.
  423. </p>
  424. <h3 id="StaticTokenSource">func <a href="http://localhost:6060/src/github.com/dghubble/oauth1/token.go?s=673:721#L19">StaticTokenSource</a></h3>
  425. <pre>func StaticTokenSource(token *<a href="index.html#Token">Token</a>) <a href="index.html#TokenSource">TokenSource</a></pre>
  426. <p>
  427. StaticTokenSource returns a TokenSource which always returns the same Token.
  428. This is appropriate for tokens which do not have a time expiration.
  429. </p>
  430. <h2 id="Transport">type <a href="http://localhost:6060/src/github.com/dghubble/oauth1/transport.go?s=330:641#L4">Transport</a></h2>
  431. <pre>type Transport struct {
  432. <span class="comment">// Base is the base RoundTripper used to make HTTP requests. If nil, then</span>
  433. <span class="comment">// http.DefaultTransport is used</span>
  434. Base <a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#RoundTripper">RoundTripper</a>
  435. <span class="comment">// contains filtered or unexported fields</span>
  436. }</pre>
  437. <p>
  438. Transport is an http.RoundTripper which makes OAuth1 HTTP requests. It
  439. wraps a base RoundTripper and adds an Authorization header using the
  440. token from a TokenSource.
  441. </p>
  442. <p>
  443. Transport is a low-level component, most users should use Config to create
  444. an http.Client instead.
  445. </p>
  446. <h3 id="Transport.RoundTrip">func (*Transport) <a href="http://localhost:6060/src/github.com/dghubble/oauth1/transport.go?s=758:830#L16">RoundTrip</a></h3>
  447. <pre>func (t *<a href="index.html#Transport">Transport</a>) RoundTrip(req *<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Request">Request</a>) (*<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Response">Response</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  448. <p>
  449. RoundTrip authorizes the request with a signed OAuth1 Authorization header
  450. using the auther and TokenSource.
  451. </p>
  452. <h2 id="pkg-subdirectories">Subdirectories</h2>
  453. <div class="pkg-dir">
  454. <table>
  455. <tr>
  456. <th class="pkg-name">Name</th>
  457. <th class="pkg-synopsis">Synopsis</th>
  458. </tr>
  459. <tr>
  460. <td colspan="2"><a href="../index.html">..</a></td>
  461. </tr>
  462. <tr>
  463. <td class="pkg-name" style="padding-left: 0px;">
  464. <a href="dropbox/index.html">dropbox</a>
  465. </td>
  466. <td class="pkg-synopsis">
  467. Package dropbox provides constants for using OAuth1 to access Dropbox.
  468. </td>
  469. </tr>
  470. <tr>
  471. <td class="pkg-name" style="padding-left: 0px;">
  472. <a href="examples/index.html">examples</a>
  473. </td>
  474. <td class="pkg-synopsis">
  475. </td>
  476. </tr>
  477. <tr>
  478. <td class="pkg-name" style="padding-left: 0px;">
  479. <a href="tumblr/index.html">tumblr</a>
  480. </td>
  481. <td class="pkg-synopsis">
  482. Package tumblr provides constants for using OAuth 1 to access Tumblr.
  483. </td>
  484. </tr>
  485. <tr>
  486. <td class="pkg-name" style="padding-left: 0px;">
  487. <a href="twitter/index.html">twitter</a>
  488. </td>
  489. <td class="pkg-synopsis">
  490. Package twitter provides constants for using OAuth1 to access Twitter.
  491. </td>
  492. </tr>
  493. </table>
  494. </div>
  495. <div id="footer">
  496. Build version go1.6.<br>
  497. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  498. the content of this page is licensed under the
  499. Creative Commons Attribution 3.0 License,
  500. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  501. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  502. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  503. </div>
  504. </div><!-- .container -->
  505. </div><!-- #page -->
  506. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  507. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  508. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  509. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  510. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  511. </body>
  512. </html>