YukiGasai / obsidian-google-calendar

Add Google Calendar inside Obsidian
https://yukigasai.github.io/obsidian-google-calendar/
GNU General Public License v3.0
359 stars 25 forks source link

URI Error on Android only #192

Closed bhemmelgarn closed 11 months ago

bhemmelgarn commented 11 months ago

I have successfully logged in on a PC and a Mac, but on Android I get Error 400: redirect_uri_mismatch.

Is there a URI that I need to add for mobile? Or is there some other issue going on?

grayerbeard commented 11 months ago

I am very confused as to how to set up to use from mobile. At step 31 in the instructions Instructions where you select "Application Type" the instructions in small letters imply you need to select "Android" rathe than "Web application" but i you do you get asked for all sorts of info as if you were developing a web App. Perhaps there needs to be a separate set of instructions for setting up to use on an Adroid phone.

bhemmelgarn commented 11 months ago

I don't think that's the problem; as is, clicking login takes me to the external web app to authorize the Google login, but that's where I get the uri_mismatch error.

According to the link in 32, Setting up OAuth 2.0, it looks like "Android" is for setting up OAuth from inside Obsidian. I think that would require some heavy work to accommodate, when the web app should redirect just fine.

Edit: Wouldn't having a second OAuth Client ID also cause problems? It would have its own tokens for the login, and as written, the plugin only stores one of each.

grayerbeard commented 11 months ago

I agree that using Android instead of web app at step 32 cannot be the answer.

For me the log in one does from set up works but something not working when the app is restarted I get an error message and if I try and execute a command , e.g to bring up a list of events, I just get a blank list. Every time the app is started I get a message saying that there is an error.

YukiGasai commented 11 months ago

Hey, I tested it myself and can reproduce your result. The problem is, that I accidentally updated the mobile callback to a new url. This new url is used for the updated OAuth process from the other branch. I will update the plugin to go back to the correct documented URL. Sorry 😐

YukiGasai commented 11 months ago

Okay, I checked again and saw that I updated the documentation. Have you added https://google-auth-obsidian-redirect.vercel.app as Javascript Source URI and https://google-auth-obsidian-redirect.vercel.app/callback as Redirect URL?

grayerbeard commented 11 months ago

This below shows the settings that I have always had since I set it up on September 11th (and it worked always Ok on my Laptop but not Android)

Client ID for Web application URL1 http://127.0.0.1:42813 URL2 https://google-auth-obsidian-redirect.vercel.app

Authorized redirect URIs http://127.0.0.1:42813/callback https://google-auth-obsidian-redirect.vercel.app/callback

So I guess you will change the Mobile Plugin soon tou work with them, I just wait a while.

Thanks for the quick responce.

YukiGasai commented 11 months ago

I wish it was that easy, but my first comment was kind of wrong, the switch to the new URL already happened and should work. I tested with two phones and my login works. What version of the plugin are you using?

grayerbeard commented 11 months ago

I am on version 1.10.5 on my phone and 1.10.4 on my Laptop.. On phone if I go to plug in and go where the id and secret are and log in seems to log in etc ok but does not show any info if execute a command. When Obsidian starts get message That Plug in "Not logged in or settings missing". On Laptop seems to work from a command but does not show any of the events that are set in my Google Calendar.

YukiGasai commented 11 months ago

Wait so you don't get the Error 400: redirect_uri_mismatch? In that case, please check for any errors in the Developer Console Ctrl + Shift + i. You can also check if the Access and Refresh Token are stored in the Local Storage of the Obsidian application. image

grayerbeard commented 11 months ago

I could not get Ctrl + Shift + i to do anything on my phone but I could find my way to that folder shown in your pic, the folder that on my laptop has the "data.json" file in it using a file manager with "show hidden files" enabled. On my phone there is only three files in that folder - no data.json. Currently I am trying to see if I can copy over the data.json file but no luck so far.

YukiGasai commented 11 months ago

The hotkey should work on your laptop.

grayerbeard commented 11 months ago

Yes fine on laptop, ctrl + shift + i works there, but not on android,, also now managed to install your PlugIn on my little Lenovo Android Tablet and all works fine, log in an app functions. I am now thinking problem could be the type of phone, its an Xiaomi Redme Note 9 with Xiaomi's own odd version of Android which I have found particularly frustrating sometimes with respect to settings; (such as default apps) being missing altogether. I am inclined to give up especially as my Little Tablet is OK.

YukiGasai commented 11 months ago

Thank you for your testing. I can completely agree with you here. I used the Redmi Note 8 and it was so bad that I decided to switch to a pixel. A last point of error could be that the browser doesn't allow the obsidian application to start when the OAuth process in the browser is finished and the browser is redirected to obsidian://.....

bhemmelgarn commented 11 months ago

For the record, I have a Pixel Pro 7, running version plugin 1.10.5 with both of the specified URI's. I don't think they're revealing, but screenshots attached in the next comment.

In Obsidian, I can create new events, but they don't sync and I can't import existing events. I can try to get into the mobile dev console for more info, but it will probably be a couple days until I have the time.

bhemmelgarn commented 11 months ago

Screenshot_20230921-080349~2 Screenshot_20230921-080358~2

YukiGasai commented 11 months ago

Hi @bhemmelgarn, from your screenshots, it looks like the correct URL is used. But it seems like there is a problem with the configuration. Can you please send a screenshot of the Google cloud configuration page. Example: image

bhemmelgarn commented 11 months ago

It is an exact match. I tried to force https, but debugged that out on desktop.

image
YukiGasai commented 11 months ago

Use http for the 127.0.0.1 and https for the other url and it will work. Make sure to update both JavaScript Origin and Redirect URI.

bhemmelgarn commented 11 months ago

I'm not sure what changed exactly, but it just worked? I also have the Google Tasks plugin running, and I got finished getting the refresh token to mobile yesterday, maybe that is involved somehow? IDK. Sorry I can't identify the bug, but thank you for your persistence!