Skip to content

difficulty getting oauth file with yagmail #261

Open
@kramsman

Description

@kramsman

Dear Github,

I am looking forward to using yagmail, but am having a devil of a time getting authorization to work. After first trying to set my gmail account to less secure, I learned this apparently is no longer allowed and Oauth 2 is required.

My issue is much like the one specified in this thread, . As stated in this post, #143 (comment), it appears that google does not supply the credential file in the correct format. But I tried a bunch of things and each had its own problem.

  • When I set up a Client ID in the Google API console, download the json as credentials.json and let the system create the token.json, things work to a point: I am brought through google to "pick an account, do you want to continue" and token is created. I am able to print labels for the gmail account. But when I issue yag.send(to='xxx@gmail.com', subject='Testing Yagmail', contents='Hurray, it worked!'), I get an error "TypeError: refresh_authorization() got an unexpected keyword argument 'token'." When I look at the token file, it does contain the key 'token' which it should not per Oauth2 issue: TypeError: refresh_authorization() got an unexpected keyword argument 'installed' #143 (comment).
  • If I go into the token and edit it to reflect the the expected contents as identified in the above link by removing keys that are not specified and prefixing the names with 'google_', I get an error "ValueError: Authorized user info was not in the expected format, missing fields refresh_token, client_id, client_secret." It doesn't seem to like the 'google_' prefix.
  • editing the token file as above without the 'google_' prefix seems to get further producing a different error "An error occurred: <HttpError 403 when requesting https://gmail.googleapis.com/gmail/v1/users/me/labels?alt=json returned "Request had insufficient authentication scopes"

I am stuck. Relatively new to Oauth2, but it seems others are able to use yagmail. Is there a trick I am missing? I am also new to Github but hope my post gives the right amount of info.

Thanks for any assistance,
Brian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions