-var oauthConfig = &oauth2.Config{
- ClientID: app.Config.GoogleClientID,
- ClientSecret: app.Config.GoogleClientSecret,
- Endpoint: oauth2google.Endpoint,
- RedirectURL: "https://kraftakt.octo.it/google/grant",
- Scopes: []string{
- fitness.FitnessActivityWriteScope,
- fitness.FitnessBodyWriteScope,
- fitness.FitnessLocationWriteScope,
- },
+func oauthConfig() *oauth2.Config {
+ return &oauth2.Config{
+ ClientID: app.Config.GoogleClientID,
+ ClientSecret: app.Config.GoogleClientSecret,
+ Endpoint: oauth2google.Endpoint,
+ RedirectURL: "https://kraftakt.octo.it/google/grant",
+ Scopes: []string{
+ fitness.FitnessActivityWriteScope,
+ fitness.FitnessBodyWriteScope,
+ fitness.FitnessLocationWriteScope,
+ },
+ }
+}
+
+func AuthURL(ctx context.Context, u *app.User) string {
+ return oauthConfig().AuthCodeURL(u.Sign("Google"), oauth2.AccessTypeOffline)