Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用Microsoft Azure App获取redirect url #73

Open
Lijiachen1018 opened this issue Sep 7, 2020 · 0 comments
Open

用Microsoft Azure App获取redirect url #73

Lijiachen1018 opened this issue Sep 7, 2020 · 0 comments

Comments

@Lijiachen1018
Copy link

自己尝试之后找到的办法
Microsoft Azure
-> Manage Azure Active Directory
-> App registrations
-> new registration

需要替换的就是 /utils/static.pyApplication (client) ID, Redirect URIs, Client Secret 三个参数,
Client ID 在 App overview 中查看; 在 Certificates & secrets -> new client secret ,创建了client secret
下面是 redirect uri 获取,注册好app之后,

  1. Redirect URIs -> Add a platform -> web application -> 填入 redirect URI
    点Web app之后找到一个 quick start -> python -> Step 2 download the code sample,解压后是一个简单的 flask 服务
    在服务器后台挂起服务 nohup python app.py &
    如果在自己 pc/mac 上启动 onedrivecmd 和flask服务,redirect URI 是 http://localhost:5000/getAToken
    如果在服务器上,redirect URI 是 https://ip:5000/getAToken,ip是服务器ip,如果服务器需要转发还得nginx转发到外网ip,注意是https不是http
    如果端口被占用,需要修改端口,那么app.py修改最后一行 app.run(port=8090),这里我设置端口8090,可以是其他没有占用端口
  2. 修改 onedrivecmd/utils/static.py 中 client_id_normal ,client_secret_normal, redirect_uri
    conda env list 查看虚拟环境安装地址,cd 虚拟环境文件夹, 然后用find ./ -name onedrivecmd
  3. 修改 onedrivecmd 和 onedrivesdk 源码
    a. 找到源码位置find ./ -name onedrivesdk
    b. 发现由于onedrivesdk发送参数应该是string导致了错误,需要修改 onedrivesdk/auth_provider.py 第194行添上
params = "client_id=" + str(self.client_id) + '&redirect_uri=' + str(redirect_uri) +'&client_secret=' + str(client_secret) + '&code=' + str(code) +'&grant_type=authorization_code'

然后根据作者的 onedrivecmd init ……就可以使用了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant