benweet / stackedit

In-browser Markdown editor
https://stackedit.io/
Apache License 2.0
21.49k stars 2.7k forks source link

can't open the google photo to inset image #1750

Open evannan opened 2 years ago

evannan commented 2 years ago

can't open the google photo to inset image when i uesd the top buttom to insert image from google. the popwindow show me:

Google

  1. That’s an error. We're sorry, but you do not have access to this page. That’s all we know.
dcode commented 2 years ago

#

I'm getting this too. I dug a bit deeper, but I'm not sure where to go from here. I'd be happy to help fix it because this is a showstopper for my use-case (namely, I have to have some form of drag-drop or click to upload photo). I just don't know where to go from here.

My app is configured with Google OAuth2 ClientID, Secret, and API key. I enabled the following APIs in the project:

I looked through the rest of the available APIs and didn't see anything relevant.

Next I looked at the traffic and noticed that the Google Drive iframe uses the same picker API, just a different nav parameter.

Here's a request with the picker for Google Drive, which works just fine

Google Picker to open file from Drive

GET /picker?protocol=gadgets&origin=https%3A%2F%2F<MYSTACKEDIT-DOMAIN>&oauth_token=<MY-TOKEN>&std=true&title&multiselectEnabled=true&hostId=<MYSTACKEDIT-DOMAIN>&parent=https%3A%2F%2F<MYSTACKEDIT-DOMAIN>%2Ffavicon.ico&nav=((%22all%22%2Cnull%2C%7B%22mimeTypes%22%3A%22text%2Fplain%2Ctext%2Fx-markdown%2Capplication%2Foctet-stream%22%7D)%2C(%22all%22%2Cnull%2C%7B%22mimeTypes%22%3A%22text%2Fplain%2Ctext%2Fx-markdown%2Capplication%2Foctet-stream%22%2C%22td%22%3Atrue%7D))&rpcService=<MY-RPCSERVICE-ID>&rpctoken=<MY-RPCSERVICE-TOKEN>&thirdParty=true HTTP/1.1
Host: docs.google.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
DNT: 1
Alt-Used: docs.google.com
Connection: keep-alive
Referer: https://<MYSTACKEDIT-DOMAIN>/
Cookie: <MY-COOKIES>
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Pragma: no-cache
Cache-Control: no-cache

Google Picker to "Open from Google Photos"

GET /picker?protocol=gadgets&origin=https%3A%2F%2F<MYSTACKEDIT-DOMAIN>&oauth_token=<MY-TOKEN>&std=true&title&hostId=<MYSTACKEDIT-DOMAIN>&parent=https%3A%2F%2F<MYSTACKEDIT-DOMAIN>%2Ffavicon.ico&nav=((%22photos%22%2Cnull%2C%7B%22type%22%3A%22highlights%22%7D)%2C(%22photo-upload%22))&rpcService=<MY-RPCSERVICE-ID>&rpctoken=<MY-RPCSERVICE-TOKEN>&thirdParty=true HTTP/1.1
Host: docs.google.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
DNT: 1
Alt-Used: docs.google.com
Connection: keep-alive
Referer: https://<MYSTACKEDIT-DOMAIN>/
Cookie: <MY-COOKIES>
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Pragma: no-cache
Cache-Control: no-cache

Checked my local tokens, and it appears the photo and drive scopes are both present.

{
  "id": "tokens",
  "type": "data",
  "data": {
    "google": {
      "<TOKEN-ID>": {
        "scopes": [
          "https://www.googleapis.com/auth/photos",
          "https://www.googleapis.com/auth/drive.appdata",
          "https://www.googleapis.com/auth/drive",
          "https://www.googleapis.com/auth/drive.install"
        ],
        "accessToken": "<MY-ACCESS_TOKEN>",
        "expiresOn": 1644528654920,
        "idToken": "<MY-ID-TOKEN>",
        "sub": "<MY-SUB-WHATEVERTHATIS>",
        "name": "dcode",
        "isLogin": true,
        "isSponsor": false,
        "isDrive": true,
        "isBlogger": false,
        "isPhotos": true,
        "driveFullAccess": true
      }
    }
  },
  "hash": -1
}