Hi! I did my best to overhaul the authentication to handle both OAuth and JWT. As an informal overview, there would now be two steps to authenticating: setting the type with aw_auth_with and then calling aw_auth to actually carry out the authentication. The results are stored in a hidden environment .adobeanalytics and internal functions retrieve the token with retrieve_aw_token.
# Assume environment variables are set up for now
aw_auth_with("oauth") # Sets auth type for session
aw_auth()
# Alternatively, you can pass the type directly to aw_auth
aw_auth("oauth")
There's a subtle difference between these two ways of authenticating. If you set aw_auth_with() in a new session, you can start calling query functions like aw_get_metrics without authenticating. If you don't set aw_auth_with() and try to call a query function, it will throw an error because it doesn't know which method to try by default.
You can also set the caching path and filename with the functions aw_auth_path and aw_auth_name.
I added a new R6 object, AdobeJwtToken, to handle the JWT authentication. This stores the httrrequest object as well as the user's authentication details. As with httr::oauth_service_token(), the response is never cached, but it can be refreshed with AdobeJwtToken$refresh().
Summary
Goals
Keep auth easy for the end-user, despite adding a different type of token
Add abstraction to auth implementation to be token-agnostic at the higher level functions
Avoid breaking existing code where possible
Allow the use of JWT token authentication and add refreshing for this type of token, per the AA 2.0 docs
Features
The aw_call_api function (and related functions) don't know which type of token is being used, they are given config settings by get_token_config
Add accessors to common options to make it easy to set/get the auth type, cache path, and cache name
Problems
I don't have an OAuth token, so I must rely on you to help me debug that code
The last few lines of retrieve_aw_token need to be checked in particular
Breaking changes
My goal was none, although aw_token now throws a lifecycle warning. It would be nice to have no breaking changes if possible, so please help me if I made mistakes with the OAuth parts.
Hi! I did my best to overhaul the authentication to handle both OAuth and JWT. As an informal overview, there would now be two steps to authenticating: setting the type with
aw_auth_with
and then callingaw_auth
to actually carry out the authentication. The results are stored in a hidden environment.adobeanalytics
and internal functions retrieve the token withretrieve_aw_token
.There's a subtle difference between these two ways of authenticating. If you set
aw_auth_with()
in a new session, you can start calling query functions likeaw_get_metrics
without authenticating. If you don't setaw_auth_with()
and try to call a query function, it will throw an error because it doesn't know which method to try by default.You can also set the caching path and filename with the functions
aw_auth_path
andaw_auth_name
.I added a new R6 object,
AdobeJwtToken
, to handle the JWT authentication. This stores thehttr
request
object as well as the user's authentication details. As withhttr::oauth_service_token()
, the response is never cached, but it can be refreshed withAdobeJwtToken$refresh()
.Summary
Goals
Features
aw_call_api
function (and related functions) don't know which type of token is being used, they are given config settings byget_token_config
Problems
retrieve_aw_token
need to be checked in particularBreaking changes
My goal was none, although
aw_token
now throws a lifecycle warning. It would be nice to have no breaking changes if possible, so please help me if I made mistakes with the OAuth parts.Final to-dos