Namespaces | Functions
oauth2_credentials.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <map>
#include <memory>
#include <vector>
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/http/httpcli_ssl_credentials.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/json/json.h"
#include "src/core/lib/promise/context.h"
#include "src/core/lib/promise/poll.h"
#include "src/core/lib/promise/promise.h"
#include "src/core/lib/security/util/json_util.h"
#include "src/core/lib/slice/slice_refcount.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/uri/uri_parser.h"
Include dependency graph for oauth2_credentials.cc:

Go to the source code of this file.

Namespaces

 grpc_core
 

Functions

static std::string create_loggable_refresh_token (grpc_auth_refresh_token *token)
 
grpc_call_credentialsgrpc_access_token_credentials_create (const char *access_token, void *reserved)
 
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json (const Json &json)
 
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string (const char *json_string)
 
void grpc_auth_refresh_token_destruct (grpc_auth_refresh_token *refresh_token)
 Destructs the object. More...
 
int grpc_auth_refresh_token_is_valid (const grpc_auth_refresh_token *refresh_token)
 Returns 1 if the object is valid, 0 otherwise. More...
 
grpc_call_credentialsgrpc_google_compute_engine_credentials_create (void *reserved)
 
grpc_call_credentialsgrpc_google_refresh_token_credentials_create (const char *json_refresh_token, void *reserved)
 
grpc_credentials_status grpc_oauth2_token_fetcher_credentials_parse_server_response (const grpc_http_response *response, absl::optional< grpc_core::Slice > *token_value, grpc_core::Duration *token_lifetime)
 
grpc_core::RefCountedPtr< grpc_call_credentialsgrpc_refresh_token_credentials_create_from_auth_refresh_token (grpc_auth_refresh_token refresh_token)
 
grpc_call_credentialsgrpc_sts_credentials_create (const grpc_sts_credentials_options *options, void *reserved)
 
static void on_oauth2_token_fetcher_http_response (void *user_data, grpc_error_handle error)
 
absl::StatusOr< URI > grpc_core::ValidateStsCredentialsOptions (const grpc_sts_credentials_options *options)
 

Function Documentation

◆ create_loggable_refresh_token()

static std::string create_loggable_refresh_token ( grpc_auth_refresh_token token)
static

Definition at line 497 of file oauth2_credentials.cc.

◆ grpc_access_token_credentials_create()

grpc_call_credentials* grpc_access_token_credentials_create ( const char *  access_token,
void *  reserved 
)

Creates an Oauth2 Access Token credentials with an access token that was acquired by an out of band mechanism.

Definition at line 744 of file oauth2_credentials.cc.

◆ grpc_auth_refresh_token_create_from_json()

grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json ( const grpc_core::Json json)

Creates a refresh token object from parsed json. Returns an invalid object if a parsing error has been encountered.

Definition at line 79 of file oauth2_credentials.cc.

◆ grpc_auth_refresh_token_create_from_string()

grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string ( const char *  json_string)

Creates a refresh token object from string. Returns an invalid object if a parsing error has been encountered.

Definition at line 115 of file oauth2_credentials.cc.

◆ grpc_auth_refresh_token_destruct()

void grpc_auth_refresh_token_destruct ( grpc_auth_refresh_token refresh_token)

Destructs the object.

Definition at line 127 of file oauth2_credentials.cc.

◆ grpc_auth_refresh_token_is_valid()

int grpc_auth_refresh_token_is_valid ( const grpc_auth_refresh_token refresh_token)

Returns 1 if the object is valid, 0 otherwise.

Definition at line 73 of file oauth2_credentials.cc.

◆ grpc_google_compute_engine_credentials_create()

grpc_call_credentials* grpc_google_compute_engine_credentials_create ( void *  reserved)

Creates a compute engine credentials object for connecting to Google. WARNING: Do NOT use this credentials to connect to a non-google service as this could result in an oauth2 token leak.

Definition at line 421 of file oauth2_credentials.cc.

◆ grpc_google_refresh_token_credentials_create()

grpc_call_credentials* grpc_google_refresh_token_credentials_create ( const char *  json_refresh_token,
void *  reserved 
)

Creates an Oauth2 Refresh Token credentials object for connecting to Google. May return NULL if the input is invalid. WARNING: Do NOT use this credentials to connect to a non-google service as this could result in an oauth2 token leak.

  • json_refresh_token is the JSON string containing the refresh token itself along with a client_id and client_secret.

Definition at line 508 of file oauth2_credentials.cc.

◆ grpc_oauth2_token_fetcher_credentials_parse_server_response()

grpc_credentials_status grpc_oauth2_token_fetcher_credentials_parse_server_response ( const grpc_http_response response,
absl::optional< grpc_core::Slice > *  token_value,
grpc_core::Duration token_lifetime 
)

Definition at line 155 of file oauth2_credentials.cc.

◆ grpc_refresh_token_credentials_create_from_auth_refresh_token()

grpc_core::RefCountedPtr<grpc_call_credentials> grpc_refresh_token_credentials_create_from_auth_refresh_token ( grpc_auth_refresh_token  refresh_token)

Definition at line 476 of file oauth2_credentials.cc.

◆ grpc_sts_credentials_create()

grpc_call_credentials* grpc_sts_credentials_create ( const grpc_sts_credentials_options options,
void *  reserved 
)

Creates an STS credentials following the STS Token Exchanged specifed in the IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. This API is used for experimental purposes for now and may change in the future.

Definition at line 701 of file oauth2_credentials.cc.

◆ on_oauth2_token_fetcher_http_response()

static void on_oauth2_token_fetcher_http_response ( void *  user_data,
grpc_error_handle  error 
)
static

Definition at line 238 of file oauth2_credentials.cc.

Variable Documentation

◆ actor_token_path_

UniquePtr<char> actor_token_path_
private

Definition at line 656 of file oauth2_credentials.cc.

◆ actor_token_type_

UniquePtr<char> actor_token_type_
private

Definition at line 657 of file oauth2_credentials.cc.

◆ audience_

UniquePtr<char> audience_
private

Definition at line 651 of file oauth2_credentials.cc.

◆ http_post_cb_closure_

grpc_closure http_post_cb_closure_
private

Definition at line 649 of file oauth2_credentials.cc.

◆ http_request_

OrphanablePtr<HttpRequest> http_request_
private

Definition at line 658 of file oauth2_credentials.cc.

◆ requested_token_type_

UniquePtr<char> requested_token_type_
private

Definition at line 653 of file oauth2_credentials.cc.

◆ resource_

UniquePtr<char> resource_
private

Definition at line 650 of file oauth2_credentials.cc.

◆ scope_

UniquePtr<char> scope_
private

Definition at line 652 of file oauth2_credentials.cc.

◆ sts_url_

URI sts_url_
private

Definition at line 648 of file oauth2_credentials.cc.

◆ subject_token_path_

UniquePtr<char> subject_token_path_
private

Definition at line 654 of file oauth2_credentials.cc.

◆ subject_token_type_

UniquePtr<char> subject_token_type_
private

Definition at line 655 of file oauth2_credentials.cc.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:24