mirror of
https://github.com/vwxyzjn/portwarden
synced 2025-12-23 02:53:12 +00:00
API-6 # Make sure refresh token works
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/vwxyzjn/portwarden/web/server"
|
"github.com/vwxyzjn/portwarden/web/scheduler/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package server
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/vwxyzjn/portwarden"
|
"github.com/vwxyzjn/portwarden"
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -33,7 +35,7 @@ func EncryptBackupHandler(c *gin.Context) {
|
|||||||
// Not sure if it's supposed to call UploadFile() directly
|
// Not sure if it's supposed to call UploadFile() directly
|
||||||
func (ps *PortwardenServer) GetGoogleDriveLoginURLHandler(c *gin.Context) {
|
func (ps *PortwardenServer) GetGoogleDriveLoginURLHandler(c *gin.Context) {
|
||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"login_url": ps.GoogleDriveAppConfig.AuthCodeURL("state-token"),
|
"login_url": ps.GoogleDriveAppConfig.AuthCodeURL("state-token", oauth2.AccessTypeOffline, oauth2.ApprovalForce),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -49,7 +51,8 @@ func (ps *PortwardenServer) GetGoogleDriveLoginHandler(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error(), "message": ErrRetrievingOauthCode})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error(), "message": ErrRetrievingOauthCode})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GoogleDriveClient := ps.GoogleDriveAppConfig.Client(ps.GoogleDriveContext, tok)
|
spew.Dump(tok)
|
||||||
|
GoogleDriveClient := ps.GoogleDriveAppConfig.Client(oauth2.NoContext, tok)
|
||||||
fileBytes := []byte("xixix")
|
fileBytes := []byte("xixix")
|
||||||
err = UploadFile(fileBytes, GoogleDriveClient, tok)
|
err = UploadFile(fileBytes, GoogleDriveClient, tok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user