Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # OAuth2 for Go
  2. [![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2)
  3. [![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/oauth2)
  4. oauth2 package contains a client implementation for OAuth 2.0 spec.
  5. ## Installation
  6. ~~~~
  7. go get golang.org/x/oauth2
  8. ~~~~
  9. Or you can manually git clone the repository to
  10. `$(go env GOPATH)/src/golang.org/x/oauth2`.
  11. See godoc for further documentation and examples.
  12. * [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2)
  13. * [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google)
  14. ## App Engine
  15. In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor
  16. of the [`context.Context`](https://golang.org/x/net/context#Context) type from
  17. the `golang.org/x/net/context` package
  18. This means it's no longer possible to use the "Classic App Engine"
  19. `appengine.Context` type with the `oauth2` package. (You're using
  20. Classic App Engine if you import the package `"appengine"`.)
  21. To work around this, you may use the new `"google.golang.org/appengine"`
  22. package. This package has almost the same API as the `"appengine"` package,
  23. but it can be fetched with `go get` and used on "Managed VMs" and well as
  24. Classic App Engine.
  25. See the [new `appengine` package's readme](https://github.com/golang/appengine#updating-a-go-app-engine-app)
  26. for information on updating your app.
  27. If you don't want to update your entire app to use the new App Engine packages,
  28. you may use both sets of packages in parallel, using only the new packages
  29. with the `oauth2` package.
  30. ```go
  31. import (
  32. "golang.org/x/net/context"
  33. "golang.org/x/oauth2"
  34. "golang.org/x/oauth2/google"
  35. newappengine "google.golang.org/appengine"
  36. newurlfetch "google.golang.org/appengine/urlfetch"
  37. "appengine"
  38. )
  39. func handler(w http.ResponseWriter, r *http.Request) {
  40. var c appengine.Context = appengine.NewContext(r)
  41. c.Infof("Logging a message with the old package")
  42. var ctx context.Context = newappengine.NewContext(r)
  43. client := &http.Client{
  44. Transport: &oauth2.Transport{
  45. Source: google.AppEngineTokenSource(ctx, "scope"),
  46. Base: &newurlfetch.Transport{Context: ctx},
  47. },
  48. }
  49. client.Get("...")
  50. }
  51. ```
  52. ## Report Issues / Send Patches
  53. This repository uses Gerrit for code changes. To learn how to submit changes to
  54. this repository, see https://golang.org/doc/contribute.html.
  55. The main issue tracker for the oauth2 repository is located at
  56. https://github.com/golang/oauth2/issues.