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.
 
 
 

1449 lines
44 KiB

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