Comments (17)
@FrnkPsycho REFRESH_TOKEN
应该只有这些,准确来说是 354 字符:
from onedrive-cf-index.
@spencerwooo 感谢回复!
我也试着用insomnia手动post 但是结果还是一样的 密钥还是那么长...
而且我发现我的token开头非常很奇怪,不知道有没有关系
或许可能是因为onedrive账号的原因?我的账号是office a1订阅
from onedrive-cf-index.
@FrnkPsycho 可能是 OneDrive 账号问题,你实在存不下的话,试试把你的 refresh_token
单独存到 Firebase 里面,然后像调用 access_token
这里 /src/auth/onedrive.js 去请求。
from onedrive-cf-index.
我也有同样的问题,是office E5订阅,请问您能说详细一些吗? @spencerwooo
@FrnkPsycho 可能是 OneDrive 账号问题,你实在存不下的话,试试把你的
refresh_token
单独存到 Firebase 里面,然后像调用access_token
这里 /src/auth/onedrive.js 去请求。
from onedrive-cf-index.
另外,是access_token也要存到Firebase 里面吗?
还有,Firebase那里,是新建一个没有值的键:
auth:''
就可以了,对吗?
from onedrive-cf-index.
另外,是
access_token
也要存到 Firebase 里面吗?
不是,上面是说 Cloudflare 的环境变量有长度限制情况下的 workaround:把刷新 access_token
用的 refresh_token
存在 Firebase 里面。之后 onedrive-cf-index
会在 Cloudflare Workers 上面通过你存好的 refresh_token
来自动刷新和存储 access_token
等一系列鉴权参数。总之:
access_token
应该是onedrive-cf-index
自动获取并缓存到 Firebase 的;refresh_token
则是我们手动获取一次之后存储在 Cloudflare Workers 环境变量或在长度溢出情况下手动存在 Firebase 里面的。
还有,Firebase 那里,是新建一个没有值的键:
auth: ''
就可以了,对吗?
是的,应该没问题,Firebase 里面存储的 auth
值类似这样子:
from onedrive-cf-index.
@Micraow @FrnkPsycho 手动存 refresh_token
的话,可以在这里手动新建一个值叫做 refresh_token
并填入你手动获取的 Token:
这样你就可以在 ./src/config/default.js 需要你填入 REFRESH_TOKEN
这里通过类似这样的方法获取这个 token 了:
别看了,这个有 bug……看下面:#issuecomment-681968724
// ./src/config/default.js
const refresh_token = await (await fetch(`https://<你的 Firebase URL 地址>/refresh_token.json?auth=${FIREBASE_TOKEN}`)).text()
const config = {
/**
* You can use this tool http://heymind.github.io/tools/microsoft-graph-api-auth
* to get following params: client_id, client_secret, refresh_token & redirect_uri.
*/
refresh_token: refresh_token,
// ...
}
from onedrive-cf-index.
好的,谢谢,但是今天下午我发现。我的令牌已经变回了原来的那种QAQ的样子,所以我就直接添加了。
from onedrive-cf-index.
@spencerwooo 可能问题有点笨,毕竟没有学习js的经验,所以只能copy您给出的代码,然后出现了一下错误
C:\Users\Calmpsycho\Documents\onedrive-cf-index-master>wrangler preview
./src/config/default.js 1:29
Module parse failed: Cannot use keyword 'await' outside an async function (1:29)
You may need an appropriate loader to handle this file type.
> const refresh_token = await (await fetch(`https://{非常认真地填写了地址}/refresh_token.json?auth=${FIREBASE_TOKEN}`)).text()
|
|
@ ./src/index.js 1:0-37 38:13-19 43:6-12 43:22-28 48:15-21 54:20-26 55:18-24 57:30-36 106:10-16 109:31-37
Error: webpack returned an error. You may be able to resolve this issue by running npm install.
好像是什么语法的问题?希望能照顾我这个小白订正一下QAQ
from onedrive-cf-index.
@spencerwooo 可能问题有点笨,毕竟没有学习js的经验,所以只能copy您给出的代码,然后出现了一下错误
C:\Users\Calmpsycho\Documents\onedrive-cf-index-master>wrangler preview ./src/config/default.js 1:29 Module parse failed: Cannot use keyword 'await' outside an async function (1:29) You may need an appropriate loader to handle this file type. > const refresh_token = await (await fetch(`https://{非常认真地填写了地址}/refresh_token.json?auth=${FIREBASE_TOKEN}`)).text() | | @ ./src/index.js 1:0-37 38:13-19 43:6-12 43:22-28 48:15-21 54:20-26 55:18-24 57:30-36 106:10-16 109:31-37 Error: webpack returned an error. You may be able to resolve this issue by running npm install.
好像是什么语法的问题?希望能照顾我这个小白订正一下QAQ
oh shit,不对,这么写有问题,我傻了,我重新本地写一下,稍等。
Edit: @FrnkPsycho 这个 refresh_token
只有 ./src/auth/onedrive.js
里面用到了,在这个文件里面:
// ./src/auth/onedrive.js
export async function getAccessToken() {
const timestamp = () => {
return Math.floor(Date.now() / 1000)
}
const refresh_token = await (await fetch(`https://<你的 Firebase URL 地址>/refresh_token.json?auth=${FIREBASE_TOKEN}`)).text()
// 之后所有的 config.refresh_token 都直接改为 refresh_token
// ...
}
from onedrive-cf-index.
@spencerwooo 解决了 感谢!
不过我发现了和之前heymind大佬那个项目一样的问题,单个目录只能显示200个文件夹,请问这是onedrive本身问题还是cloudflare的请求限制?
能够解决我的疑问就更好了
from onedrive-cf-index.
@FrnkPsycho 单个目录只能显示 200 个文件夹是我没写 pagination,其实是可以支持的,OneDrive 有 API,等我有空实现,可以开个新 issue 来 track 这个问题。
from onedrive-cf-index.
请问一下大佬,按照这个issue配置好之后,使用wrangler preview之后显示:
worker.js:1 Uncaught ReferenceError: REFRESH_TOKEN is not defined
at Module.<anonymous> (worker.js:1)
at t (worker.js:1)
at worker.js:1
at worker.js:1
onedrive.js里面写的是:
const refresh_token = await (await fetch(`https://认真的抄写/refresh_token.json?auth=${FIREBASE_TOKEN}`)).text()
// Fetch access token from Google Firebase Database
const data = await (await fetch(`${config.firebase_url}?auth=${FIREBASE_TOKEN}`)).json()
if (data && data.access_token && timestamp() < data.expire_at) {
console.log('Fetched token from storage.')
return data.access_token
}
const resp = await fetch(oneDriveAuthEndpoint, {
method: 'POST',
body: `client_id=${config.client_id}&redirect_uri=${config.redirect_uri}&client_secret=${config.client_secret}
&refresh_token=${refresh_token}&grant_type=refresh_token`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
from onedrive-cf-index.
请问一下大佬,按照这个issue配置好之后,使用wrangler preview之后显示:
worker.js:1 Uncaught ReferenceError: REFRESH_TOKEN is not defined at Module.<anonymous> (worker.js:1) at t (worker.js:1) at worker.js:1 at worker.js:1
@FaintGhost 你得把 src/config/default.js
里面的 REFRESH_TOKEN
删掉,如果你用这个办法的话,因为你这时候并没有在 Cloudflare Workers 里面定义 REFRESH_TOKEN
这个环境变量,所以这里才会报错的。
from onedrive-cf-index.
感谢回复,但是我把src/config/default.js
里的REFRESH_TOKEN
删掉之后就会变成另一个错误如下:
Uncaught (in promise) getAccessToken error "{\"error\":\"invalid_grant\",\"error_description\":\"AADSTS9002313: Invalid request. Request is malformed or invalid.\\r\\nTrace ID: 5fc808fa-f814-4478-af81-e060452e2800\\r\\nCorrelation ID: 19baf150-6226-467f-a264-7d8b0183ca54\\r\\nTimestamp: 2020-09-21 02:14:16Z\",\"error_codes\":[9002313],\"timestamp\":\"2020-09-21 02:14:16Z\",\"trace_id\":\"5fc808fa-f814-4478-af81-e060452e2800\",\"correlation_id\":\"19baf150-6226-467f-a264-7d8b0183ca54\",\"error_uri\":\"https://login.microsoftonline.com/error?code=9002313\"}"
Uncaught (in response) Error: internal error
from onedrive-cf-index.
@FaintGhost 那你这里还是后面请求的配置问题
from onedrive-cf-index.
哭瞎了,我乖乖按照教程配置的,我试了一下如果直接把refresh_token
填写在src/config/default.js
文件就可以正常使用,但是不知道这样会不会有什么影响
from onedrive-cf-index.
Related Issues (20)
- wrangler login 执行时卡在 Waiting for API token... HOT 2
- 希望能添加个视图预览 HOT 1
- cloudflare works 使用路由开文件提示重定向次数过多 HOT 1
- 关于上传文件问题
- Custom domain does not works HOT 1
- 从使用 wrangler 添加 Cloudflare Workers 环境变量开始报错(小白求助) HOT 10
- [bug?] OAuth Refresh token过期 HOT 2
- Preview cache (seems to) break Markdown preview
- 使用Insomnia获取refresh_token被告知code已过期
- 从6月份开始,Cf用户报错Worker threw exception,我这边报错Script Threw Exception,重新再来还是如此。 HOT 1
- Error 1101 Worker threw exception HOT 2
- 能否添加一个图床功能 HOT 2
- 叨扰大佬一下 我捣鼓了一晚上 一直获取不了refresh_token HOT 1
- It's not necessary to register new applications HOT 1
- 找不到 zone_id HOT 4
- Publish时出现以下错误 HOT 4
- 输入wrangler login 命令后报错 HOT 1
- Custom Domain Worker threw exception 1101 [自訂域名拋出 1101 錯誤] HOT 1
- 在进行到修改 src/config/default.js后该怎么办呢,是像原heymind一样将js填入worker的部署页面还是怎么操作呢(本人纯新手,不懂wrangler知识) HOT 1
- Markdown渲染base64编码图片时出现错误
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onedrive-cf-index.