1
0
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:
Costa Huang
2018-11-27 17:49:46 -05:00
parent fa0eb81157
commit 10d1bfe3f0
2 changed files with 6 additions and 3 deletions

View File

@@ -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() {

View File

@@ -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 {