-
Notifications
You must be signed in to change notification settings - Fork 56
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
gm_auth_configure() failing to auth with custom app provided via htrr::oauth_app() #144
Comments
Not sure if my issue is related, but I am also having trouble authorizing an app. I followed instructions here to create my app and credentials, and downloaded a json file. But when I reference the file with My json file is formed like this: {
"type": "service_account",
"project_id": "project-id",
"private_key_id": "",
"private_key": "-----BEGIN PRIVATE KEY-----\n[redacted]\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "client_id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/my-app.iam.gserviceaccount.com"
} There is no value called "client_secret" or similar. Is it possible something has changed, or am I creating my app the wrong way? |
+1 @hannahflaherty, also, when I try with the OAuth JSON file, pasted below, I get the same error: Are we getting the right JSON file? Or we need to pass another argument to
|
Hi @jeanprado were you able to solve this? I'm also getting the |
Getting the same error when using |
+1 |
Same, I think the package is build to receive an old json structure |
This comment has been minimized.
This comment has been minimized.
I just became maintainer of gmailr a couple of days ago, so it's my first time reading this thread. I can't truly work on gmailr right now, but I'll try to at least bring some clarity here today. |
Would one say Congratulations about that? I imagine it probably means more on an already full plate though! |
There are few different problems mixed together in this thread. I'm going to work through a few of them. @hannahflaherty The JSON you show is for a service account, but you say you want to "authoriz[e] an app". This is a pretty common mix up, i.e. to have the JSON for a service account, but then present it to gargle as an OAuth client (or vice versa). This fails, for obvious reasons. You need to get an OAuth 2.0 client ID and secret and gargle's instruction for this are here: https://gargle.r-lib.org/articles/get-api-credentials.html. |
@jeanprado The JSON you show indicates you've gotten an OAuth client for use in web applications (see the The application type should be “Desktop app”. |
Updating with more details: For gargle < 1.0.0, the JSON for a web application OAuth client would be rejected by
As of gargle >= 1.0.0 (released 2021-03-03), the JSON for a web application will be accepted, because it is useful to other packages (e.g. googleAuthR) and for some development experiments in gargle. But note that gargle itself does not really offer proper support (yet) for a true web app auth flow. In particular, gmailr and its use of gargle expect a "Desktop app" OAuth client. Here is where this error originates, which explains why gargle will not see a https://github.com/r-lib/gargle/blob/5f8fb44b5de7d0120e5a48e58fe8d89c7fbb6bc6/R/oauth-app.R#L24-L30 For those of you seeing In short, many of the problems reported here (although ironically not what the original poster is reporting) come from having an unexpected OAuth client type. |
@yogat3ch This thread is (mostly) not about service accounts, so I'm not going to follow up on that here and that is why I'm marking such comments as off-topic. |
So just to update on the original topic: While using the syntax from OP like following:
doesn't work. If you pass additional arguments (key, secret) into gm_auth_configure call, everything works fine. Example of working code (note: values of "key" and "secret" in both oauth_app and gm_auth_configure are identical):
|
Yeah, now that I've addressed all the off-topic stuff, I can return the original problem report, which doesn't look too difficult to fix. |
Right now, while attempting to run first auth using custom app setup (see code below), gm_auth_configure() returns error requesting either for path or key and secret parameters.
Not 100% sure if this is an error or just inconsistency with function documetation which uses code like below as an example. However, with other gargle-based apps, similar code works like charm
Code:
Error returned:
My sessionInfo():
The text was updated successfully, but these errors were encountered: