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.
 
 
 

1354 line
41 KiB

  1. // Package oauth2 provides access to the Google OAuth2 API.
  2. //
  3. // See https://developers.google.com/accounts/docs/OAuth2
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/oauth2/v1"
  8. // ...
  9. // oauth2Service, err := oauth2.New(oauthHttpClient)
  10. package oauth2 // import "google.golang.org/api/oauth2/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "oauth2:v1"
  41. const apiName = "oauth2"
  42. const apiVersion = "v1"
  43. const basePath = "https://www.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Know the list of people in your circles, your age range, and language
  47. PlusLoginScope = "https://www.googleapis.com/auth/plus.login"
  48. // Know who you are on Google
  49. PlusMeScope = "https://www.googleapis.com/auth/plus.me"
  50. // View your email address
  51. UserinfoEmailScope = "https://www.googleapis.com/auth/userinfo.email"
  52. // View your basic profile info
  53. UserinfoProfileScope = "https://www.googleapis.com/auth/userinfo.profile"
  54. )
  55. func New(client *http.Client) (*Service, error) {
  56. if client == nil {
  57. return nil, errors.New("client is nil")
  58. }
  59. s := &Service{client: client, BasePath: basePath}
  60. s.Userinfo = NewUserinfoService(s)
  61. return s, nil
  62. }
  63. type Service struct {
  64. client *http.Client
  65. BasePath string // API endpoint base URL
  66. UserAgent string // optional additional User-Agent fragment
  67. Userinfo *UserinfoService
  68. }
  69. func (s *Service) userAgent() string {
  70. if s.UserAgent == "" {
  71. return googleapi.UserAgent
  72. }
  73. return googleapi.UserAgent + " " + s.UserAgent
  74. }
  75. func NewUserinfoService(s *Service) *UserinfoService {
  76. rs := &UserinfoService{s: s}
  77. rs.V2 = NewUserinfoV2Service(s)
  78. return rs
  79. }
  80. type UserinfoService struct {
  81. s *Service
  82. V2 *UserinfoV2Service
  83. }
  84. func NewUserinfoV2Service(s *Service) *UserinfoV2Service {
  85. rs := &UserinfoV2Service{s: s}
  86. rs.Me = NewUserinfoV2MeService(s)
  87. return rs
  88. }
  89. type UserinfoV2Service struct {
  90. s *Service
  91. Me *UserinfoV2MeService
  92. }
  93. func NewUserinfoV2MeService(s *Service) *UserinfoV2MeService {
  94. rs := &UserinfoV2MeService{s: s}
  95. return rs
  96. }
  97. type UserinfoV2MeService struct {
  98. s *Service
  99. }
  100. type Jwk struct {
  101. Keys []*JwkKeys `json:"keys,omitempty"`
  102. // ServerResponse contains the HTTP response code and headers from the
  103. // server.
  104. googleapi.ServerResponse `json:"-"`
  105. // ForceSendFields is a list of field names (e.g. "Keys") to
  106. // unconditionally include in API requests. By default, fields with
  107. // empty values are omitted from API requests. However, any non-pointer,
  108. // non-interface field appearing in ForceSendFields will be sent to the
  109. // server regardless of whether the field is empty or not. This may be
  110. // used to include empty fields in Patch requests.
  111. ForceSendFields []string `json:"-"`
  112. // NullFields is a list of field names (e.g. "Keys") to include in API
  113. // requests with the JSON null value. By default, fields with empty
  114. // values are omitted from API requests. However, any field with an
  115. // empty value appearing in NullFields will be sent to the server as
  116. // null. It is an error if a field in this list has a non-empty value.
  117. // This may be used to include null fields in Patch requests.
  118. NullFields []string `json:"-"`
  119. }
  120. func (s *Jwk) MarshalJSON() ([]byte, error) {
  121. type NoMethod Jwk
  122. raw := NoMethod(*s)
  123. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  124. }
  125. type JwkKeys struct {
  126. Alg string `json:"alg,omitempty"`
  127. E string `json:"e,omitempty"`
  128. Kid string `json:"kid,omitempty"`
  129. Kty string `json:"kty,omitempty"`
  130. N string `json:"n,omitempty"`
  131. Use string `json:"use,omitempty"`
  132. // ForceSendFields is a list of field names (e.g. "Alg") to
  133. // unconditionally include in API requests. By default, fields with
  134. // empty values are omitted from API requests. However, any non-pointer,
  135. // non-interface field appearing in ForceSendFields will be sent to the
  136. // server regardless of whether the field is empty or not. This may be
  137. // used to include empty fields in Patch requests.
  138. ForceSendFields []string `json:"-"`
  139. // NullFields is a list of field names (e.g. "Alg") to include in API
  140. // requests with the JSON null value. By default, fields with empty
  141. // values are omitted from API requests. However, any field with an
  142. // empty value appearing in NullFields will be sent to the server as
  143. // null. It is an error if a field in this list has a non-empty value.
  144. // This may be used to include null fields in Patch requests.
  145. NullFields []string `json:"-"`
  146. }
  147. func (s *JwkKeys) MarshalJSON() ([]byte, error) {
  148. type NoMethod JwkKeys
  149. raw := NoMethod(*s)
  150. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  151. }
  152. type Raw struct {
  153. Keyvalues []*RawKeyvalues `json:"keyvalues,omitempty"`
  154. // ServerResponse contains the HTTP response code and headers from the
  155. // server.
  156. googleapi.ServerResponse `json:"-"`
  157. // ForceSendFields is a list of field names (e.g. "Keyvalues") to
  158. // unconditionally include in API requests. By default, fields with
  159. // empty values are omitted from API requests. However, any non-pointer,
  160. // non-interface field appearing in ForceSendFields will be sent to the
  161. // server regardless of whether the field is empty or not. This may be
  162. // used to include empty fields in Patch requests.
  163. ForceSendFields []string `json:"-"`
  164. // NullFields is a list of field names (e.g. "Keyvalues") to include in
  165. // API requests with the JSON null value. By default, fields with empty
  166. // values are omitted from API requests. However, any field with an
  167. // empty value appearing in NullFields will be sent to the server as
  168. // null. It is an error if a field in this list has a non-empty value.
  169. // This may be used to include null fields in Patch requests.
  170. NullFields []string `json:"-"`
  171. }
  172. func (s *Raw) MarshalJSON() ([]byte, error) {
  173. type NoMethod Raw
  174. raw := NoMethod(*s)
  175. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  176. }
  177. type RawKeyvalues struct {
  178. Algorithm string `json:"algorithm,omitempty"`
  179. Exponent string `json:"exponent,omitempty"`
  180. Keyid string `json:"keyid,omitempty"`
  181. Modulus string `json:"modulus,omitempty"`
  182. // ForceSendFields is a list of field names (e.g. "Algorithm") to
  183. // unconditionally include in API requests. By default, fields with
  184. // empty values are omitted from API requests. However, any non-pointer,
  185. // non-interface field appearing in ForceSendFields will be sent to the
  186. // server regardless of whether the field is empty or not. This may be
  187. // used to include empty fields in Patch requests.
  188. ForceSendFields []string `json:"-"`
  189. // NullFields is a list of field names (e.g. "Algorithm") to include in
  190. // API requests with the JSON null value. By default, fields with empty
  191. // values are omitted from API requests. However, any field with an
  192. // empty value appearing in NullFields will be sent to the server as
  193. // null. It is an error if a field in this list has a non-empty value.
  194. // This may be used to include null fields in Patch requests.
  195. NullFields []string `json:"-"`
  196. }
  197. func (s *RawKeyvalues) MarshalJSON() ([]byte, error) {
  198. type NoMethod RawKeyvalues
  199. raw := NoMethod(*s)
  200. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  201. }
  202. type Tokeninfo struct {
  203. // AccessType: The access type granted with this token. It can be
  204. // offline or online.
  205. AccessType string `json:"access_type,omitempty"`
  206. // Audience: Who is the intended audience for this token. In general the
  207. // same as issued_to.
  208. Audience string `json:"audience,omitempty"`
  209. // Email: The email address of the user. Present only if the email scope
  210. // is present in the request.
  211. Email string `json:"email,omitempty"`
  212. // EmailVerified: Boolean flag which is true if the email address is
  213. // verified. Present only if the email scope is present in the request.
  214. EmailVerified bool `json:"email_verified,omitempty"`
  215. // ExpiresIn: The expiry time of the token, as number of seconds left
  216. // until expiry.
  217. ExpiresIn int64 `json:"expires_in,omitempty"`
  218. // IssuedAt: The issue time of the token, as number of seconds.
  219. IssuedAt int64 `json:"issued_at,omitempty"`
  220. // IssuedTo: To whom was the token issued to. In general the same as
  221. // audience.
  222. IssuedTo string `json:"issued_to,omitempty"`
  223. // Issuer: Who issued the token.
  224. Issuer string `json:"issuer,omitempty"`
  225. // Nonce: Nonce of the id token.
  226. Nonce string `json:"nonce,omitempty"`
  227. // Scope: The space separated list of scopes granted to this token.
  228. Scope string `json:"scope,omitempty"`
  229. // UserId: The obfuscated user id.
  230. UserId string `json:"user_id,omitempty"`
  231. // VerifiedEmail: Boolean flag which is true if the email address is
  232. // verified. Present only if the email scope is present in the request.
  233. VerifiedEmail bool `json:"verified_email,omitempty"`
  234. // ServerResponse contains the HTTP response code and headers from the
  235. // server.
  236. googleapi.ServerResponse `json:"-"`
  237. // ForceSendFields is a list of field names (e.g. "AccessType") to
  238. // unconditionally include in API requests. By default, fields with
  239. // empty values are omitted from API requests. However, any non-pointer,
  240. // non-interface field appearing in ForceSendFields will be sent to the
  241. // server regardless of whether the field is empty or not. This may be
  242. // used to include empty fields in Patch requests.
  243. ForceSendFields []string `json:"-"`
  244. // NullFields is a list of field names (e.g. "AccessType") to include in
  245. // API requests with the JSON null value. By default, fields with empty
  246. // values are omitted from API requests. However, any field with an
  247. // empty value appearing in NullFields will be sent to the server as
  248. // null. It is an error if a field in this list has a non-empty value.
  249. // This may be used to include null fields in Patch requests.
  250. NullFields []string `json:"-"`
  251. }
  252. func (s *Tokeninfo) MarshalJSON() ([]byte, error) {
  253. type NoMethod Tokeninfo
  254. raw := NoMethod(*s)
  255. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  256. }
  257. type Userinfoplus struct {
  258. // Email: The user's email address.
  259. Email string `json:"email,omitempty"`
  260. // FamilyName: The user's last name.
  261. FamilyName string `json:"family_name,omitempty"`
  262. // Gender: The user's gender.
  263. Gender string `json:"gender,omitempty"`
  264. // GivenName: The user's first name.
  265. GivenName string `json:"given_name,omitempty"`
  266. // Hd: The hosted domain e.g. example.com if the user is Google apps
  267. // user.
  268. Hd string `json:"hd,omitempty"`
  269. // Id: The obfuscated ID of the user.
  270. Id string `json:"id,omitempty"`
  271. // Link: URL of the profile page.
  272. Link string `json:"link,omitempty"`
  273. // Locale: The user's preferred locale.
  274. Locale string `json:"locale,omitempty"`
  275. // Name: The user's full name.
  276. Name string `json:"name,omitempty"`
  277. // Picture: URL of the user's picture image.
  278. Picture string `json:"picture,omitempty"`
  279. // VerifiedEmail: Boolean flag which is true if the email address is
  280. // verified. Always verified because we only return the user's primary
  281. // email address.
  282. //
  283. // Default: true
  284. VerifiedEmail *bool `json:"verified_email,omitempty"`
  285. // ServerResponse contains the HTTP response code and headers from the
  286. // server.
  287. googleapi.ServerResponse `json:"-"`
  288. // ForceSendFields is a list of field names (e.g. "Email") to
  289. // unconditionally include in API requests. By default, fields with
  290. // empty values are omitted from API requests. However, any non-pointer,
  291. // non-interface field appearing in ForceSendFields will be sent to the
  292. // server regardless of whether the field is empty or not. This may be
  293. // used to include empty fields in Patch requests.
  294. ForceSendFields []string `json:"-"`
  295. // NullFields is a list of field names (e.g. "Email") to include in API
  296. // requests with the JSON null value. By default, fields with empty
  297. // values are omitted from API requests. However, any field with an
  298. // empty value appearing in NullFields will be sent to the server as
  299. // null. It is an error if a field in this list has a non-empty value.
  300. // This may be used to include null fields in Patch requests.
  301. NullFields []string `json:"-"`
  302. }
  303. func (s *Userinfoplus) MarshalJSON() ([]byte, error) {
  304. type NoMethod Userinfoplus
  305. raw := NoMethod(*s)
  306. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  307. }
  308. // method id "oauth2.getCertForOpenIdConnect":
  309. type GetCertForOpenIdConnectCall struct {
  310. s *Service
  311. urlParams_ gensupport.URLParams
  312. ifNoneMatch_ string
  313. ctx_ context.Context
  314. header_ http.Header
  315. }
  316. // GetCertForOpenIdConnect:
  317. func (s *Service) GetCertForOpenIdConnect() *GetCertForOpenIdConnectCall {
  318. c := &GetCertForOpenIdConnectCall{s: s, urlParams_: make(gensupport.URLParams)}
  319. return c
  320. }
  321. // Fields allows partial responses to be retrieved. See
  322. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  323. // for more information.
  324. func (c *GetCertForOpenIdConnectCall) Fields(s ...googleapi.Field) *GetCertForOpenIdConnectCall {
  325. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  326. return c
  327. }
  328. // IfNoneMatch sets the optional parameter which makes the operation
  329. // fail if the object's ETag matches the given value. This is useful for
  330. // getting updates only after the object has changed since the last
  331. // request. Use googleapi.IsNotModified to check whether the response
  332. // error from Do is the result of In-None-Match.
  333. func (c *GetCertForOpenIdConnectCall) IfNoneMatch(entityTag string) *GetCertForOpenIdConnectCall {
  334. c.ifNoneMatch_ = entityTag
  335. return c
  336. }
  337. // Context sets the context to be used in this call's Do method. Any
  338. // pending HTTP request will be aborted if the provided context is
  339. // canceled.
  340. func (c *GetCertForOpenIdConnectCall) Context(ctx context.Context) *GetCertForOpenIdConnectCall {
  341. c.ctx_ = ctx
  342. return c
  343. }
  344. // Header returns an http.Header that can be modified by the caller to
  345. // add HTTP headers to the request.
  346. func (c *GetCertForOpenIdConnectCall) Header() http.Header {
  347. if c.header_ == nil {
  348. c.header_ = make(http.Header)
  349. }
  350. return c.header_
  351. }
  352. func (c *GetCertForOpenIdConnectCall) doRequest(alt string) (*http.Response, error) {
  353. reqHeaders := make(http.Header)
  354. for k, v := range c.header_ {
  355. reqHeaders[k] = v
  356. }
  357. reqHeaders.Set("User-Agent", c.s.userAgent())
  358. if c.ifNoneMatch_ != "" {
  359. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  360. }
  361. var body io.Reader = nil
  362. c.urlParams_.Set("alt", alt)
  363. urls := googleapi.ResolveRelative(c.s.BasePath, "oauth2/v1/certs")
  364. urls += "?" + c.urlParams_.Encode()
  365. req, _ := http.NewRequest("GET", urls, body)
  366. req.Header = reqHeaders
  367. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  368. }
  369. // Do executes the "oauth2.getCertForOpenIdConnect" call.
  370. func (c *GetCertForOpenIdConnectCall) Do(opts ...googleapi.CallOption) (map[string]string, error) {
  371. gensupport.SetOptions(c.urlParams_, opts...)
  372. res, err := c.doRequest("json")
  373. if err != nil {
  374. return nil, err
  375. }
  376. defer googleapi.CloseBody(res)
  377. if err := googleapi.CheckResponse(res); err != nil {
  378. return nil, err
  379. }
  380. var ret map[string]string
  381. target := &ret
  382. if err := gensupport.DecodeResponse(target, res); err != nil {
  383. return nil, err
  384. }
  385. return ret, nil
  386. // {
  387. // "httpMethod": "GET",
  388. // "id": "oauth2.getCertForOpenIdConnect",
  389. // "path": "oauth2/v1/certs",
  390. // "response": {
  391. // "$ref": "X509"
  392. // }
  393. // }
  394. }
  395. // method id "oauth2.getCertForOpenIdConnectRaw":
  396. type GetCertForOpenIdConnectRawCall struct {
  397. s *Service
  398. urlParams_ gensupport.URLParams
  399. ifNoneMatch_ string
  400. ctx_ context.Context
  401. header_ http.Header
  402. }
  403. // GetCertForOpenIdConnectRaw:
  404. func (s *Service) GetCertForOpenIdConnectRaw() *GetCertForOpenIdConnectRawCall {
  405. c := &GetCertForOpenIdConnectRawCall{s: s, urlParams_: make(gensupport.URLParams)}
  406. return c
  407. }
  408. // Fields allows partial responses to be retrieved. See
  409. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  410. // for more information.
  411. func (c *GetCertForOpenIdConnectRawCall) Fields(s ...googleapi.Field) *GetCertForOpenIdConnectRawCall {
  412. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  413. return c
  414. }
  415. // IfNoneMatch sets the optional parameter which makes the operation
  416. // fail if the object's ETag matches the given value. This is useful for
  417. // getting updates only after the object has changed since the last
  418. // request. Use googleapi.IsNotModified to check whether the response
  419. // error from Do is the result of In-None-Match.
  420. func (c *GetCertForOpenIdConnectRawCall) IfNoneMatch(entityTag string) *GetCertForOpenIdConnectRawCall {
  421. c.ifNoneMatch_ = entityTag
  422. return c
  423. }
  424. // Context sets the context to be used in this call's Do method. Any
  425. // pending HTTP request will be aborted if the provided context is
  426. // canceled.
  427. func (c *GetCertForOpenIdConnectRawCall) Context(ctx context.Context) *GetCertForOpenIdConnectRawCall {
  428. c.ctx_ = ctx
  429. return c
  430. }
  431. // Header returns an http.Header that can be modified by the caller to
  432. // add HTTP headers to the request.
  433. func (c *GetCertForOpenIdConnectRawCall) Header() http.Header {
  434. if c.header_ == nil {
  435. c.header_ = make(http.Header)
  436. }
  437. return c.header_
  438. }
  439. func (c *GetCertForOpenIdConnectRawCall) doRequest(alt string) (*http.Response, error) {
  440. reqHeaders := make(http.Header)
  441. for k, v := range c.header_ {
  442. reqHeaders[k] = v
  443. }
  444. reqHeaders.Set("User-Agent", c.s.userAgent())
  445. if c.ifNoneMatch_ != "" {
  446. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  447. }
  448. var body io.Reader = nil
  449. c.urlParams_.Set("alt", alt)
  450. urls := googleapi.ResolveRelative(c.s.BasePath, "oauth2/v1/raw_public_keys")
  451. urls += "?" + c.urlParams_.Encode()
  452. req, _ := http.NewRequest("GET", urls, body)
  453. req.Header = reqHeaders
  454. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  455. }
  456. // Do executes the "oauth2.getCertForOpenIdConnectRaw" call.
  457. // Exactly one of *Raw or error will be non-nil. Any non-2xx status code
  458. // is an error. Response headers are in either
  459. // *Raw.ServerResponse.Header or (if a response was returned at all) in
  460. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  461. // whether the returned error was because http.StatusNotModified was
  462. // returned.
  463. func (c *GetCertForOpenIdConnectRawCall) Do(opts ...googleapi.CallOption) (*Raw, error) {
  464. gensupport.SetOptions(c.urlParams_, opts...)
  465. res, err := c.doRequest("json")
  466. if res != nil && res.StatusCode == http.StatusNotModified {
  467. if res.Body != nil {
  468. res.Body.Close()
  469. }
  470. return nil, &googleapi.Error{
  471. Code: res.StatusCode,
  472. Header: res.Header,
  473. }
  474. }
  475. if err != nil {
  476. return nil, err
  477. }
  478. defer googleapi.CloseBody(res)
  479. if err := googleapi.CheckResponse(res); err != nil {
  480. return nil, err
  481. }
  482. ret := &Raw{
  483. ServerResponse: googleapi.ServerResponse{
  484. Header: res.Header,
  485. HTTPStatusCode: res.StatusCode,
  486. },
  487. }
  488. target := &ret
  489. if err := gensupport.DecodeResponse(target, res); err != nil {
  490. return nil, err
  491. }
  492. return ret, nil
  493. // {
  494. // "httpMethod": "GET",
  495. // "id": "oauth2.getCertForOpenIdConnectRaw",
  496. // "path": "oauth2/v1/raw_public_keys",
  497. // "response": {
  498. // "$ref": "Raw"
  499. // }
  500. // }
  501. }
  502. // method id "oauth2.getRobotJwk":
  503. type GetRobotJwkCall struct {
  504. s *Service
  505. robotEmail string
  506. urlParams_ gensupport.URLParams
  507. ifNoneMatch_ string
  508. ctx_ context.Context
  509. header_ http.Header
  510. }
  511. // GetRobotJwk:
  512. func (s *Service) GetRobotJwk(robotEmail string) *GetRobotJwkCall {
  513. c := &GetRobotJwkCall{s: s, urlParams_: make(gensupport.URLParams)}
  514. c.robotEmail = robotEmail
  515. return c
  516. }
  517. // Fields allows partial responses to be retrieved. See
  518. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  519. // for more information.
  520. func (c *GetRobotJwkCall) Fields(s ...googleapi.Field) *GetRobotJwkCall {
  521. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  522. return c
  523. }
  524. // IfNoneMatch sets the optional parameter which makes the operation
  525. // fail if the object's ETag matches the given value. This is useful for
  526. // getting updates only after the object has changed since the last
  527. // request. Use googleapi.IsNotModified to check whether the response
  528. // error from Do is the result of In-None-Match.
  529. func (c *GetRobotJwkCall) IfNoneMatch(entityTag string) *GetRobotJwkCall {
  530. c.ifNoneMatch_ = entityTag
  531. return c
  532. }
  533. // Context sets the context to be used in this call's Do method. Any
  534. // pending HTTP request will be aborted if the provided context is
  535. // canceled.
  536. func (c *GetRobotJwkCall) Context(ctx context.Context) *GetRobotJwkCall {
  537. c.ctx_ = ctx
  538. return c
  539. }
  540. // Header returns an http.Header that can be modified by the caller to
  541. // add HTTP headers to the request.
  542. func (c *GetRobotJwkCall) Header() http.Header {
  543. if c.header_ == nil {
  544. c.header_ = make(http.Header)
  545. }
  546. return c.header_
  547. }
  548. func (c *GetRobotJwkCall) doRequest(alt string) (*http.Response, error) {
  549. reqHeaders := make(http.Header)
  550. for k, v := range c.header_ {
  551. reqHeaders[k] = v
  552. }
  553. reqHeaders.Set("User-Agent", c.s.userAgent())
  554. if c.ifNoneMatch_ != "" {
  555. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  556. }
  557. var body io.Reader = nil
  558. c.urlParams_.Set("alt", alt)
  559. urls := googleapi.ResolveRelative(c.s.BasePath, "service_accounts/v1/jwk/{robotEmail}")
  560. urls += "?" + c.urlParams_.Encode()
  561. req, _ := http.NewRequest("GET", urls, body)
  562. req.Header = reqHeaders
  563. googleapi.Expand(req.URL, map[string]string{
  564. "robotEmail": c.robotEmail,
  565. })
  566. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  567. }
  568. // Do executes the "oauth2.getRobotJwk" call.
  569. // Exactly one of *Jwk or error will be non-nil. Any non-2xx status code
  570. // is an error. Response headers are in either
  571. // *Jwk.ServerResponse.Header or (if a response was returned at all) in
  572. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  573. // whether the returned error was because http.StatusNotModified was
  574. // returned.
  575. func (c *GetRobotJwkCall) Do(opts ...googleapi.CallOption) (*Jwk, error) {
  576. gensupport.SetOptions(c.urlParams_, opts...)
  577. res, err := c.doRequest("json")
  578. if res != nil && res.StatusCode == http.StatusNotModified {
  579. if res.Body != nil {
  580. res.Body.Close()
  581. }
  582. return nil, &googleapi.Error{
  583. Code: res.StatusCode,
  584. Header: res.Header,
  585. }
  586. }
  587. if err != nil {
  588. return nil, err
  589. }
  590. defer googleapi.CloseBody(res)
  591. if err := googleapi.CheckResponse(res); err != nil {
  592. return nil, err
  593. }
  594. ret := &Jwk{
  595. ServerResponse: googleapi.ServerResponse{
  596. Header: res.Header,
  597. HTTPStatusCode: res.StatusCode,
  598. },
  599. }
  600. target := &ret
  601. if err := gensupport.DecodeResponse(target, res); err != nil {
  602. return nil, err
  603. }
  604. return ret, nil
  605. // {
  606. // "httpMethod": "GET",
  607. // "id": "oauth2.getRobotJwk",
  608. // "parameterOrder": [
  609. // "robotEmail"
  610. // ],
  611. // "parameters": {
  612. // "robotEmail": {
  613. // "description": "The email of robot account.",
  614. // "location": "path",
  615. // "required": true,
  616. // "type": "string"
  617. // }
  618. // },
  619. // "path": "service_accounts/v1/jwk/{robotEmail}",
  620. // "response": {
  621. // "$ref": "Jwk"
  622. // }
  623. // }
  624. }
  625. // method id "oauth2.getRobotMetadataRaw":
  626. type GetRobotMetadataRawCall struct {
  627. s *Service
  628. robotEmail string
  629. urlParams_ gensupport.URLParams
  630. ifNoneMatch_ string
  631. ctx_ context.Context
  632. header_ http.Header
  633. }
  634. // GetRobotMetadataRaw:
  635. func (s *Service) GetRobotMetadataRaw(robotEmail string) *GetRobotMetadataRawCall {
  636. c := &GetRobotMetadataRawCall{s: s, urlParams_: make(gensupport.URLParams)}
  637. c.robotEmail = robotEmail
  638. return c
  639. }
  640. // Fields allows partial responses to be retrieved. See
  641. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  642. // for more information.
  643. func (c *GetRobotMetadataRawCall) Fields(s ...googleapi.Field) *GetRobotMetadataRawCall {
  644. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  645. return c
  646. }
  647. // IfNoneMatch sets the optional parameter which makes the operation
  648. // fail if the object's ETag matches the given value. This is useful for
  649. // getting updates only after the object has changed since the last
  650. // request. Use googleapi.IsNotModified to check whether the response
  651. // error from Do is the result of In-None-Match.
  652. func (c *GetRobotMetadataRawCall) IfNoneMatch(entityTag string) *GetRobotMetadataRawCall {
  653. c.ifNoneMatch_ = entityTag
  654. return c
  655. }
  656. // Context sets the context to be used in this call's Do method. Any
  657. // pending HTTP request will be aborted if the provided context is
  658. // canceled.
  659. func (c *GetRobotMetadataRawCall) Context(ctx context.Context) *GetRobotMetadataRawCall {
  660. c.ctx_ = ctx
  661. return c
  662. }
  663. // Header returns an http.Header that can be modified by the caller to
  664. // add HTTP headers to the request.
  665. func (c *GetRobotMetadataRawCall) Header() http.Header {
  666. if c.header_ == nil {
  667. c.header_ = make(http.Header)
  668. }
  669. return c.header_
  670. }
  671. func (c *GetRobotMetadataRawCall) doRequest(alt string) (*http.Response, error) {
  672. reqHeaders := make(http.Header)
  673. for k, v := range c.header_ {
  674. reqHeaders[k] = v
  675. }
  676. reqHeaders.Set("User-Agent", c.s.userAgent())
  677. if c.ifNoneMatch_ != "" {
  678. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  679. }
  680. var body io.Reader = nil
  681. c.urlParams_.Set("alt", alt)
  682. urls := googleapi.ResolveRelative(c.s.BasePath, "service_accounts/v1/metadata/raw/{robotEmail}")
  683. urls += "?" + c.urlParams_.Encode()
  684. req, _ := http.NewRequest("GET", urls, body)
  685. req.Header = reqHeaders
  686. googleapi.Expand(req.URL, map[string]string{
  687. "robotEmail": c.robotEmail,
  688. })
  689. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  690. }
  691. // Do executes the "oauth2.getRobotMetadataRaw" call.
  692. // Exactly one of *Raw or error will be non-nil. Any non-2xx status code
  693. // is an error. Response headers are in either
  694. // *Raw.ServerResponse.Header or (if a response was returned at all) in
  695. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  696. // whether the returned error was because http.StatusNotModified was
  697. // returned.
  698. func (c *GetRobotMetadataRawCall) Do(opts ...googleapi.CallOption) (*Raw, error) {
  699. gensupport.SetOptions(c.urlParams_, opts...)
  700. res, err := c.doRequest("json")
  701. if res != nil && res.StatusCode == http.StatusNotModified {
  702. if res.Body != nil {
  703. res.Body.Close()
  704. }
  705. return nil, &googleapi.Error{
  706. Code: res.StatusCode,
  707. Header: res.Header,
  708. }
  709. }
  710. if err != nil {
  711. return nil, err
  712. }
  713. defer googleapi.CloseBody(res)
  714. if err := googleapi.CheckResponse(res); err != nil {
  715. return nil, err
  716. }
  717. ret := &Raw{
  718. ServerResponse: googleapi.ServerResponse{
  719. Header: res.Header,
  720. HTTPStatusCode: res.StatusCode,
  721. },
  722. }
  723. target := &ret
  724. if err := gensupport.DecodeResponse(target, res); err != nil {
  725. return nil, err
  726. }
  727. return ret, nil
  728. // {
  729. // "httpMethod": "GET",
  730. // "id": "oauth2.getRobotMetadataRaw",
  731. // "parameterOrder": [
  732. // "robotEmail"
  733. // ],
  734. // "parameters": {
  735. // "robotEmail": {
  736. // "description": "The email of robot account.",
  737. // "location": "path",
  738. // "required": true,
  739. // "type": "string"
  740. // }
  741. // },
  742. // "path": "service_accounts/v1/metadata/raw/{robotEmail}",
  743. // "response": {
  744. // "$ref": "Raw"
  745. // }
  746. // }
  747. }
  748. // method id "oauth2.getRobotMetadataX509":
  749. type GetRobotMetadataX509Call struct {
  750. s *Service
  751. robotEmail string
  752. urlParams_ gensupport.URLParams
  753. ifNoneMatch_ string
  754. ctx_ context.Context
  755. header_ http.Header
  756. }
  757. // GetRobotMetadataX509:
  758. func (s *Service) GetRobotMetadataX509(robotEmail string) *GetRobotMetadataX509Call {
  759. c := &GetRobotMetadataX509Call{s: s, urlParams_: make(gensupport.URLParams)}
  760. c.robotEmail = robotEmail
  761. return c
  762. }
  763. // Fields allows partial responses to be retrieved. See
  764. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  765. // for more information.
  766. func (c *GetRobotMetadataX509Call) Fields(s ...googleapi.Field) *GetRobotMetadataX509Call {
  767. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  768. return c
  769. }
  770. // IfNoneMatch sets the optional parameter which makes the operation
  771. // fail if the object's ETag matches the given value. This is useful for
  772. // getting updates only after the object has changed since the last
  773. // request. Use googleapi.IsNotModified to check whether the response
  774. // error from Do is the result of In-None-Match.
  775. func (c *GetRobotMetadataX509Call) IfNoneMatch(entityTag string) *GetRobotMetadataX509Call {
  776. c.ifNoneMatch_ = entityTag
  777. return c
  778. }
  779. // Context sets the context to be used in this call's Do method. Any
  780. // pending HTTP request will be aborted if the provided context is
  781. // canceled.
  782. func (c *GetRobotMetadataX509Call) Context(ctx context.Context) *GetRobotMetadataX509Call {
  783. c.ctx_ = ctx
  784. return c
  785. }
  786. // Header returns an http.Header that can be modified by the caller to
  787. // add HTTP headers to the request.
  788. func (c *GetRobotMetadataX509Call) Header() http.Header {
  789. if c.header_ == nil {
  790. c.header_ = make(http.Header)
  791. }
  792. return c.header_
  793. }
  794. func (c *GetRobotMetadataX509Call) doRequest(alt string) (*http.Response, error) {
  795. reqHeaders := make(http.Header)
  796. for k, v := range c.header_ {
  797. reqHeaders[k] = v
  798. }
  799. reqHeaders.Set("User-Agent", c.s.userAgent())
  800. if c.ifNoneMatch_ != "" {
  801. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  802. }
  803. var body io.Reader = nil
  804. c.urlParams_.Set("alt", alt)
  805. urls := googleapi.ResolveRelative(c.s.BasePath, "service_accounts/v1/metadata/x509/{robotEmail}")
  806. urls += "?" + c.urlParams_.Encode()
  807. req, _ := http.NewRequest("GET", urls, body)
  808. req.Header = reqHeaders
  809. googleapi.Expand(req.URL, map[string]string{
  810. "robotEmail": c.robotEmail,
  811. })
  812. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  813. }
  814. // Do executes the "oauth2.getRobotMetadataX509" call.
  815. func (c *GetRobotMetadataX509Call) Do(opts ...googleapi.CallOption) (map[string]string, error) {
  816. gensupport.SetOptions(c.urlParams_, opts...)
  817. res, err := c.doRequest("json")
  818. if err != nil {
  819. return nil, err
  820. }
  821. defer googleapi.CloseBody(res)
  822. if err := googleapi.CheckResponse(res); err != nil {
  823. return nil, err
  824. }
  825. var ret map[string]string
  826. target := &ret
  827. if err := gensupport.DecodeResponse(target, res); err != nil {
  828. return nil, err
  829. }
  830. return ret, nil
  831. // {
  832. // "httpMethod": "GET",
  833. // "id": "oauth2.getRobotMetadataX509",
  834. // "parameterOrder": [
  835. // "robotEmail"
  836. // ],
  837. // "parameters": {
  838. // "robotEmail": {
  839. // "description": "The email of robot account.",
  840. // "location": "path",
  841. // "required": true,
  842. // "type": "string"
  843. // }
  844. // },
  845. // "path": "service_accounts/v1/metadata/x509/{robotEmail}",
  846. // "response": {
  847. // "$ref": "X509"
  848. // }
  849. // }
  850. }
  851. // method id "oauth2.tokeninfo":
  852. type TokeninfoCall struct {
  853. s *Service
  854. urlParams_ gensupport.URLParams
  855. ctx_ context.Context
  856. header_ http.Header
  857. }
  858. // Tokeninfo: Get token info
  859. func (s *Service) Tokeninfo() *TokeninfoCall {
  860. c := &TokeninfoCall{s: s, urlParams_: make(gensupport.URLParams)}
  861. return c
  862. }
  863. // AccessToken sets the optional parameter "access_token": The oauth2
  864. // access token
  865. func (c *TokeninfoCall) AccessToken(accessToken string) *TokeninfoCall {
  866. c.urlParams_.Set("access_token", accessToken)
  867. return c
  868. }
  869. // IdToken sets the optional parameter "id_token": The ID token
  870. func (c *TokeninfoCall) IdToken(idToken string) *TokeninfoCall {
  871. c.urlParams_.Set("id_token", idToken)
  872. return c
  873. }
  874. // Fields allows partial responses to be retrieved. See
  875. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  876. // for more information.
  877. func (c *TokeninfoCall) Fields(s ...googleapi.Field) *TokeninfoCall {
  878. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  879. return c
  880. }
  881. // Context sets the context to be used in this call's Do method. Any
  882. // pending HTTP request will be aborted if the provided context is
  883. // canceled.
  884. func (c *TokeninfoCall) Context(ctx context.Context) *TokeninfoCall {
  885. c.ctx_ = ctx
  886. return c
  887. }
  888. // Header returns an http.Header that can be modified by the caller to
  889. // add HTTP headers to the request.
  890. func (c *TokeninfoCall) Header() http.Header {
  891. if c.header_ == nil {
  892. c.header_ = make(http.Header)
  893. }
  894. return c.header_
  895. }
  896. func (c *TokeninfoCall) doRequest(alt string) (*http.Response, error) {
  897. reqHeaders := make(http.Header)
  898. for k, v := range c.header_ {
  899. reqHeaders[k] = v
  900. }
  901. reqHeaders.Set("User-Agent", c.s.userAgent())
  902. var body io.Reader = nil
  903. c.urlParams_.Set("alt", alt)
  904. urls := googleapi.ResolveRelative(c.s.BasePath, "oauth2/v1/tokeninfo")
  905. urls += "?" + c.urlParams_.Encode()
  906. req, _ := http.NewRequest("POST", urls, body)
  907. req.Header = reqHeaders
  908. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  909. }
  910. // Do executes the "oauth2.tokeninfo" call.
  911. // Exactly one of *Tokeninfo or error will be non-nil. Any non-2xx
  912. // status code is an error. Response headers are in either
  913. // *Tokeninfo.ServerResponse.Header or (if a response was returned at
  914. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  915. // to check whether the returned error was because
  916. // http.StatusNotModified was returned.
  917. func (c *TokeninfoCall) Do(opts ...googleapi.CallOption) (*Tokeninfo, error) {
  918. gensupport.SetOptions(c.urlParams_, opts...)
  919. res, err := c.doRequest("json")
  920. if res != nil && res.StatusCode == http.StatusNotModified {
  921. if res.Body != nil {
  922. res.Body.Close()
  923. }
  924. return nil, &googleapi.Error{
  925. Code: res.StatusCode,
  926. Header: res.Header,
  927. }
  928. }
  929. if err != nil {
  930. return nil, err
  931. }
  932. defer googleapi.CloseBody(res)
  933. if err := googleapi.CheckResponse(res); err != nil {
  934. return nil, err
  935. }
  936. ret := &Tokeninfo{
  937. ServerResponse: googleapi.ServerResponse{
  938. Header: res.Header,
  939. HTTPStatusCode: res.StatusCode,
  940. },
  941. }
  942. target := &ret
  943. if err := gensupport.DecodeResponse(target, res); err != nil {
  944. return nil, err
  945. }
  946. return ret, nil
  947. // {
  948. // "description": "Get token info",
  949. // "httpMethod": "POST",
  950. // "id": "oauth2.tokeninfo",
  951. // "parameters": {
  952. // "access_token": {
  953. // "description": "The oauth2 access token",
  954. // "location": "query",
  955. // "type": "string"
  956. // },
  957. // "id_token": {
  958. // "description": "The ID token",
  959. // "location": "query",
  960. // "type": "string"
  961. // }
  962. // },
  963. // "path": "oauth2/v1/tokeninfo",
  964. // "response": {
  965. // "$ref": "Tokeninfo"
  966. // }
  967. // }
  968. }
  969. // method id "oauth2.userinfo.get":
  970. type UserinfoGetCall struct {
  971. s *Service
  972. urlParams_ gensupport.URLParams
  973. ifNoneMatch_ string
  974. ctx_ context.Context
  975. header_ http.Header
  976. }
  977. // Get: Get user info
  978. func (r *UserinfoService) Get() *UserinfoGetCall {
  979. c := &UserinfoGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  980. return c
  981. }
  982. // Fields allows partial responses to be retrieved. See
  983. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  984. // for more information.
  985. func (c *UserinfoGetCall) Fields(s ...googleapi.Field) *UserinfoGetCall {
  986. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  987. return c
  988. }
  989. // IfNoneMatch sets the optional parameter which makes the operation
  990. // fail if the object's ETag matches the given value. This is useful for
  991. // getting updates only after the object has changed since the last
  992. // request. Use googleapi.IsNotModified to check whether the response
  993. // error from Do is the result of In-None-Match.
  994. func (c *UserinfoGetCall) IfNoneMatch(entityTag string) *UserinfoGetCall {
  995. c.ifNoneMatch_ = entityTag
  996. return c
  997. }
  998. // Context sets the context to be used in this call's Do method. Any
  999. // pending HTTP request will be aborted if the provided context is
  1000. // canceled.
  1001. func (c *UserinfoGetCall) Context(ctx context.Context) *UserinfoGetCall {
  1002. c.ctx_ = ctx
  1003. return c
  1004. }
  1005. // Header returns an http.Header that can be modified by the caller to
  1006. // add HTTP headers to the request.
  1007. func (c *UserinfoGetCall) Header() http.Header {
  1008. if c.header_ == nil {
  1009. c.header_ = make(http.Header)
  1010. }
  1011. return c.header_
  1012. }
  1013. func (c *UserinfoGetCall) doRequest(alt string) (*http.Response, error) {
  1014. reqHeaders := make(http.Header)
  1015. for k, v := range c.header_ {
  1016. reqHeaders[k] = v
  1017. }
  1018. reqHeaders.Set("User-Agent", c.s.userAgent())
  1019. if c.ifNoneMatch_ != "" {
  1020. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1021. }
  1022. var body io.Reader = nil
  1023. c.urlParams_.Set("alt", alt)
  1024. urls := googleapi.ResolveRelative(c.s.BasePath, "oauth2/v1/userinfo")
  1025. urls += "?" + c.urlParams_.Encode()
  1026. req, _ := http.NewRequest("GET", urls, body)
  1027. req.Header = reqHeaders
  1028. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1029. }
  1030. // Do executes the "oauth2.userinfo.get" call.
  1031. // Exactly one of *Userinfoplus or error will be non-nil. Any non-2xx
  1032. // status code is an error. Response headers are in either
  1033. // *Userinfoplus.ServerResponse.Header or (if a response was returned at
  1034. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1035. // to check whether the returned error was because
  1036. // http.StatusNotModified was returned.
  1037. func (c *UserinfoGetCall) Do(opts ...googleapi.CallOption) (*Userinfoplus, error) {
  1038. gensupport.SetOptions(c.urlParams_, opts...)
  1039. res, err := c.doRequest("json")
  1040. if res != nil && res.StatusCode == http.StatusNotModified {
  1041. if res.Body != nil {
  1042. res.Body.Close()
  1043. }
  1044. return nil, &googleapi.Error{
  1045. Code: res.StatusCode,
  1046. Header: res.Header,
  1047. }
  1048. }
  1049. if err != nil {
  1050. return nil, err
  1051. }
  1052. defer googleapi.CloseBody(res)
  1053. if err := googleapi.CheckResponse(res); err != nil {
  1054. return nil, err
  1055. }
  1056. ret := &Userinfoplus{
  1057. ServerResponse: googleapi.ServerResponse{
  1058. Header: res.Header,
  1059. HTTPStatusCode: res.StatusCode,
  1060. },
  1061. }
  1062. target := &ret
  1063. if err := gensupport.DecodeResponse(target, res); err != nil {
  1064. return nil, err
  1065. }
  1066. return ret, nil
  1067. // {
  1068. // "description": "Get user info",
  1069. // "httpMethod": "GET",
  1070. // "id": "oauth2.userinfo.get",
  1071. // "path": "oauth2/v1/userinfo",
  1072. // "response": {
  1073. // "$ref": "Userinfoplus"
  1074. // },
  1075. // "scopes": [
  1076. // "https://www.googleapis.com/auth/plus.login",
  1077. // "https://www.googleapis.com/auth/plus.me",
  1078. // "https://www.googleapis.com/auth/userinfo.email",
  1079. // "https://www.googleapis.com/auth/userinfo.profile"
  1080. // ]
  1081. // }
  1082. }
  1083. // method id "oauth2.userinfo.v2.me.get":
  1084. type UserinfoV2MeGetCall struct {
  1085. s *Service
  1086. urlParams_ gensupport.URLParams
  1087. ifNoneMatch_ string
  1088. ctx_ context.Context
  1089. header_ http.Header
  1090. }
  1091. // Get: Get user info
  1092. func (r *UserinfoV2MeService) Get() *UserinfoV2MeGetCall {
  1093. c := &UserinfoV2MeGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1094. return c
  1095. }
  1096. // Fields allows partial responses to be retrieved. See
  1097. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1098. // for more information.
  1099. func (c *UserinfoV2MeGetCall) Fields(s ...googleapi.Field) *UserinfoV2MeGetCall {
  1100. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1101. return c
  1102. }
  1103. // IfNoneMatch sets the optional parameter which makes the operation
  1104. // fail if the object's ETag matches the given value. This is useful for
  1105. // getting updates only after the object has changed since the last
  1106. // request. Use googleapi.IsNotModified to check whether the response
  1107. // error from Do is the result of In-None-Match.
  1108. func (c *UserinfoV2MeGetCall) IfNoneMatch(entityTag string) *UserinfoV2MeGetCall {
  1109. c.ifNoneMatch_ = entityTag
  1110. return c
  1111. }
  1112. // Context sets the context to be used in this call's Do method. Any
  1113. // pending HTTP request will be aborted if the provided context is
  1114. // canceled.
  1115. func (c *UserinfoV2MeGetCall) Context(ctx context.Context) *UserinfoV2MeGetCall {
  1116. c.ctx_ = ctx
  1117. return c
  1118. }
  1119. // Header returns an http.Header that can be modified by the caller to
  1120. // add HTTP headers to the request.
  1121. func (c *UserinfoV2MeGetCall) Header() http.Header {
  1122. if c.header_ == nil {
  1123. c.header_ = make(http.Header)
  1124. }
  1125. return c.header_
  1126. }
  1127. func (c *UserinfoV2MeGetCall) doRequest(alt string) (*http.Response, error) {
  1128. reqHeaders := make(http.Header)
  1129. for k, v := range c.header_ {
  1130. reqHeaders[k] = v
  1131. }
  1132. reqHeaders.Set("User-Agent", c.s.userAgent())
  1133. if c.ifNoneMatch_ != "" {
  1134. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1135. }
  1136. var body io.Reader = nil
  1137. c.urlParams_.Set("alt", alt)
  1138. urls := googleapi.ResolveRelative(c.s.BasePath, "userinfo/v2/me")
  1139. urls += "?" + c.urlParams_.Encode()
  1140. req, _ := http.NewRequest("GET", urls, body)
  1141. req.Header = reqHeaders
  1142. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1143. }
  1144. // Do executes the "oauth2.userinfo.v2.me.get" call.
  1145. // Exactly one of *Userinfoplus or error will be non-nil. Any non-2xx
  1146. // status code is an error. Response headers are in either
  1147. // *Userinfoplus.ServerResponse.Header or (if a response was returned at
  1148. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1149. // to check whether the returned error was because
  1150. // http.StatusNotModified was returned.
  1151. func (c *UserinfoV2MeGetCall) Do(opts ...googleapi.CallOption) (*Userinfoplus, error) {
  1152. gensupport.SetOptions(c.urlParams_, opts...)
  1153. res, err := c.doRequest("json")
  1154. if res != nil && res.StatusCode == http.StatusNotModified {
  1155. if res.Body != nil {
  1156. res.Body.Close()
  1157. }
  1158. return nil, &googleapi.Error{
  1159. Code: res.StatusCode,
  1160. Header: res.Header,
  1161. }
  1162. }
  1163. if err != nil {
  1164. return nil, err
  1165. }
  1166. defer googleapi.CloseBody(res)
  1167. if err := googleapi.CheckResponse(res); err != nil {
  1168. return nil, err
  1169. }
  1170. ret := &Userinfoplus{
  1171. ServerResponse: googleapi.ServerResponse{
  1172. Header: res.Header,
  1173. HTTPStatusCode: res.StatusCode,
  1174. },
  1175. }
  1176. target := &ret
  1177. if err := gensupport.DecodeResponse(target, res); err != nil {
  1178. return nil, err
  1179. }
  1180. return ret, nil
  1181. // {
  1182. // "description": "Get user info",
  1183. // "httpMethod": "GET",
  1184. // "id": "oauth2.userinfo.v2.me.get",
  1185. // "path": "userinfo/v2/me",
  1186. // "response": {
  1187. // "$ref": "Userinfoplus"
  1188. // },
  1189. // "scopes": [
  1190. // "https://www.googleapis.com/auth/plus.login",
  1191. // "https://www.googleapis.com/auth/plus.me",
  1192. // "https://www.googleapis.com/auth/userinfo.email",
  1193. // "https://www.googleapis.com/auth/userinfo.profile"
  1194. // ]
  1195. // }
  1196. }