OAuth 2.0 client.
| 26 | |
| 27 | /// OAuth 2.0 client. |
| 28 | class OAuthClient { |
| 29 | public: |
| 30 | OAuthClient(); |
| 31 | explicit OAuthClient( |
| 32 | std::unique_ptr<HttpRequest::Factory> http_request_factory, Env* env); |
| 33 | virtual ~OAuthClient() {} |
| 34 | |
| 35 | /// \brief Retrieves a bearer token using a private key. |
| 36 | /// |
| 37 | /// Retrieves the authentication bearer token using a JSON file |
| 38 | /// with the client's private key. |
| 39 | virtual Status GetTokenFromServiceAccountJson( |
| 40 | Json::Value json, StringPiece oauth_server_uri, StringPiece scope, |
| 41 | string* token, uint64* expiration_timestamp_sec); |
| 42 | |
| 43 | /// Retrieves a bearer token using a refresh token. |
| 44 | virtual Status GetTokenFromRefreshTokenJson(Json::Value json, |
| 45 | StringPiece oauth_server_uri, |
| 46 | string* token, |
| 47 | uint64* expiration_timestamp_sec); |
| 48 | |
| 49 | /// Parses the JSON response with the token from an OAuth 2.0 server. |
| 50 | virtual Status ParseOAuthResponse(StringPiece response, |
| 51 | uint64 request_timestamp_sec, string* token, |
| 52 | uint64* expiration_timestamp_sec); |
| 53 | |
| 54 | private: |
| 55 | std::unique_ptr<HttpRequest::Factory> http_request_factory_; |
| 56 | Env* env_; |
| 57 | TF_DISALLOW_COPY_AND_ASSIGN(OAuthClient); |
| 58 | }; |
| 59 | |
| 60 | } // namespace tensorflow |
| 61 |