AddRetrieveErrorToAuthError returns the same error provided and adds a
[golang.org/x/oauth2.RetrieveError] to the error chain by setting theErrfield on the
[cloud.google.com/go/auth.Error].
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe oauth2adapt package facilitates the conversion of data types between cloud.google.com/go/auth and golang.org/x/oauth2 packages.\u003c/p\u003e\n"],["\u003cp\u003eThis package provides functions to convert Credentials types, allowing for seamless interoperability between cloud.google.com/go/auth.Credentials and golang.org/x/oauth2/google.Credentials.\u003c/p\u003e\n"],["\u003cp\u003eThe package contains functions to convert errors allowing for interoperability between cloud.google.com/go/auth.Error and golang.org/x/oauth2.RetrieveError.\u003c/p\u003e\n"],["\u003cp\u003eThis package offers functions for converting TokenSource to TokenProvider and vice versa, enabling flexibility between golang.org/x/oauth2.TokenSource and cloud.google.com/go/auth.TokenProvider.\u003c/p\u003e\n"]]],[],null,["# Package cloud.google.com/go/auth/oauth2adapt (v0.2.8)\n\nVersion latestkeyboard_arrow_down\n\n- [0.2.8 (latest)](/go/docs/reference/cloud.google.com/go/auth/oauth2adapt/latest)\n- [0.2.7](/go/docs/reference/cloud.google.com/go/auth/oauth2adapt/0.2.7) \n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/cloud.google.com/go/auth/oauth2adapt). \n\u003cbr /\u003e\n\nPackage oauth2adapt helps converts types used in [cloud.google.com/go/auth](https://pkg.go.dev/cloud.google.com/go/auth)\nand [golang.org/x/oauth2](https://pkg.go.dev/golang.org/x/oauth2). \n\nFunctions\n---------\n\n### func AddRetrieveErrorToAuthError\n\n func AddRetrieveErrorToAuthError(err */go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_Error_Error) */go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_Error_Error\n\nAddRetrieveErrorToAuthError returns the same error provided and adds a\n\\[golang.org/x/oauth2.RetrieveError\\] to the error chain by setting the `Err` field on the\n\\[cloud.google.com/go/auth.Error\\]. \n\n### func AuthCredentialsFromOauth2Credentials\n\n func AuthCredentialsFromOauth2Credentials(creds *https://pkg.go.dev/golang.org/x/oauth2/google.https://pkg.go.dev/golang.org/x/oauth2/google#Credentials) */go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_Credentials\n\nAuthCredentialsFromOauth2Credentials converts a \\[golang.org/x/oauth2/google.Credentials\\]\nto a \\[cloud.google.com/go/auth.Credentials\\]. \n\n### func AuthErrorFromRetrieveError\n\n func AuthErrorFromRetrieveError(err *https://pkg.go.dev/golang.org/x/oauth2.https://pkg.go.dev/golang.org/x/oauth2#RetrieveError) */go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_Error_Error\n\nAuthErrorFromRetrieveError returns an \\[cloud.google.com/go/auth.Error\\] that\nwraps the provided \\[golang.org/x/oauth2.RetrieveError\\]. \n\n### func Oauth2CredentialsFromAuthCredentials\n\n func Oauth2CredentialsFromAuthCredentials(creds */go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_Credentials) *https://pkg.go.dev/golang.org/x/oauth2/google.https://pkg.go.dev/golang.org/x/oauth2/google#Credentials\n\nOauth2CredentialsFromAuthCredentials converts a \\[cloud.google.com/go/auth.Credentials\\]\nto a \\[golang.org/x/oauth2/google.Credentials\\]. \n\n### func TokenProviderFromTokenSource\n\n func TokenProviderFromTokenSource(ts https://pkg.go.dev/golang.org/x/oauth2.https://pkg.go.dev/golang.org/x/oauth2#TokenSource) /go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_TokenProvider\n\nTokenProviderFromTokenSource converts any \\[golang.org/x/oauth2.TokenSource\\]\ninto a \\[cloud.google.com/go/auth.TokenProvider\\]. \n\n### func TokenSourceFromTokenProvider\n\n func TokenSourceFromTokenProvider(tp /go/docs/reference/cloud.google.com/go/auth/latest./go/docs/reference/cloud.google.com/go/auth/latest#cloud_google_com_go_auth_TokenProvider) https://pkg.go.dev/golang.org/x/oauth2.https://pkg.go.dev/golang.org/x/oauth2#TokenSource\n\nTokenSourceFromTokenProvider converts any\n\\[cloud.google.com/go/auth.TokenProvider\\] into a\n\\[golang.org/x/oauth2.TokenSource\\]."]]