-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk/azcore: TokenCredential should not be internal #17522
Comments
package main
import (
"context"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
)
// implementing TokenCredential
type CustomCredential struct {}
func (c *CustomCredential) GetToken(ctx context.Context, options policy.TokenRequestOptions) (*azcore.AccessToken, error) {
return nil, nil
}
var _ azcore.TokenCredential = (*CustomCredential)(nil)
// calling GetToken()
func main() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
panic(err)
}
tk, err := cred.GetToken(
context.TODO(), policy.TokenRequestOptions{Scopes: []string{"https://management.azure.com/.default"}},
)
if err != nil {
panic(err)
}
} |
Hi @ItalyPaleAle. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “ |
1 similar comment
Hi @ItalyPaleAle. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “ |
Thanks for the explanation. I'll take a look at that and will let you know if I run into any issue. |
For some additional context, there are two reasons why we have internal types that are exported via type aliases.
I've refactored the internal content that's actually exported under an |
Hi @ItalyPaleAle, since you haven’t asked that we “ |
Bug Report
In
sdk/azcore
, theTokenCredential
interface, as well as related structs such asTokenRequestOptions
are in an internal package and cannot be used by third-party code.We are working with APIs that are not supported by the SDKs yet, including some that have no roadmap to be supported. In order to interact with them, we need to retrieve access tokens. Because the
TokenRequestOptions
is internal, we cannot invokeGetToken
on anazcore.TokenCredential
object and retrieve an access token. Thus, we cannot make API calls without having to also re-implement the entire auth flow.sdk/azcore
0.23.0
go version
:go version go1.18 linux/amd64
The text was updated successfully, but these errors were encountered: