V
V
Vladimir Grabko2016-09-03 16:43:22
linux
Vladimir Grabko, 2016-09-03 16:43:22

How to create htp.Client if access-token exists?

golang.org/x/oauth2
There is a ClientID, ClientSecret and access token that I get by hand. We need to implement a function

buildOAuthHTTPClient(scope string) (*http.Client, error)

There is an implementation only with receiving through the browser.
config := &oauth2.Config{
    ClientID:     cfg.Installed.ClientID,
    ClientSecret: cfg.Installed.ClientSecret,
    Scopes:       []string{scope},
    Endpoint: oauth2.Endpoint{
      AuthURL:  cfg.Installed.AuthURI,
      TokenURL: cfg.Installed.TokenURI,
    },
    RedirectURL: redirectUri,
  }

config.Client(oauth2.NoContext, token)

Who has already dealt with this library, please help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2016-07-06
@syxoi

https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

ffmpeg -y -i input -c:v libx264 -preset medium -b:v 555k -pass 1 -c:a libfdk_aac -b:a 128k -f mp4 /dev/null && \
ffmpeg -i input -c:v libx264 -preset medium -b:v 555k -pass 2 -c:a libfdk_aac -b:a 128k output.mp4

0. -pass 2
1. you always need to take the source file
2. in the first pass you can write to dev null
3. -f mp4you need to specify if your input is badly recognized by ffmpeg

U
uvelichitel, 2016-09-03
@VGrabko

All fields are just strings that you can enter by hand if you know them.

config := &oauth2.Config{
    ClientID:     "YourClientID",
    ClientSecret: "YourClientSecret",
    Scopes:       []string{scope},
    Endpoint: oauth2.Endpoint{
      AuthURL:  "YourAuthURL",
      TokenURL: "YourTokenURL",
    },
    RedirectURL: "YourredirectUri",
  }
token:=oauth2.Token{
    AccessToken: "Youraccess token"
    TokenType "Bearer",
}
/*
или если у вас на руках не access token а authorization code
то можно попробовать
token:=config.Exchange(oauth2.NoContext, "authorization code")
*/
client, err:=config.Client(oauth2.NoContext, token)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question