I am trying to create a python app to add email attachments (gmail) to google drive. I have used the code from the youtuber Jie Jenn as a base but have run into issues around redirect_uri. I have tried other code examples as well, which all suffer the same fate
Background: My workplace is about to go into industrial action and we have 400+ workers. We have set up a fighting fund to compensate those who are docked pay for industrial action. In order for this to happen efficiently I have set up a gmail account where they can email their payslips. However, that could get incredibly arduous going through all the attachments every pay day. To lighten the load, I'd like to have each payslip placed into a directory for that month. From here I may be able to do other things like scrape the pdf for amount docked. Depending on how much time I have, I will add functionality as I go. We file for industrial action on Monday, so I am fast running out of time. Otherwise I would just persistently stumble along until the issue is solved. I am not an experienced coder, just someone on a constant learning journey and I find it relaxing to sit and learn new skills.
Issue: So I have logged into the google cloud dashboard and created a project. Created credentials of type 'OAuth client ID'. It is of type 'Web application' and I have set an Authorized redirect URI to http://domain.i.registered.last.night The domain A record is pointed to a linux server I have leased and it resolves fine through my ISP dns, and through various online DNS services I have tried. I have the credentials.json or client-secrets.json depending on which bit of code I am trying to use (I have tried running a few examples) and it definately says in there "redirect_uris":["http://domain.i.registered.last.night"]
However, in all examples I have tried I stumble across this message when I run the code: Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=(removed).apps.googleusercontent.com&**redirect_uri=http%3A%2F%2Flocalhost%3A51159%2F**&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.modify&state=(removed)&access_type=offline
If I copy/paste that link into my browser, I get a redirect_uri_mismatch error obviously because "localhost" is not set as the redirect_uri in my app permissions on the google dashboard. I am not sure at this stage what library is producing that link, but I would presume it was supposed to use the json file to set the redirect and if it was not the same as what was set in the google app permissions OAuth fails(as it does here)
Is anyone able to help? Thankyou