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

Add a application registration #1

Merged
merged 2 commits into from
Apr 13, 2017

Conversation

178inaba
Copy link
Contributor

@178inaba 178inaba commented Apr 13, 2017

This PR provides application registration function.
https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#apps

Usage.

func main() {
	ac := mastodon.NewAppClient(&mastodon.AppConfig{
		Server:       "https://mstdn.jp",
		ClientName:   "Test App",
		RedirectURIs: "urn:ietf:wg:oauth:2.0:oob",
	})

	app, err := ac.RegistrationApp()
	if err != nil {
		log.Fatal(err)
	}

	c := mastodon.NewClient(&mastodon.Config{
		Server:       "https://mstdn.jp",
		ClientID:     app.ClientID,
		ClientSecret: app.ClientSecret,
	})

	...
}

@mattn
Copy link
Owner

mattn commented Apr 13, 2017

No need to make instance like appClient. Please make simple func like below.

func RegisterApp(appConfig *AppConfig) (*Application, error) {
  //
}

@mattn
Copy link
Owner

mattn commented Apr 13, 2017

LGTM.

@mattn mattn merged commit ae27e93 into mattn:master Apr 13, 2017
@mattn
Copy link
Owner

mattn commented Apr 13, 2017

Thank you

@178inaba
Copy link
Contributor Author

Thank you so much for review!
I Fixed it to a simple function.

I was wondering where to place http.Client, but I put it in AppConfig.
Is this OK?

type AppConfig struct {
	http.Client

Usage.

func main() {
	app, err := mastodon.RegisterApp(&mastodon.AppConfig{
		Server:       "https://mstdn.jp",
		ClientName:   "Test App",
		RedirectURIs: "urn:ietf:wg:oauth:2.0:oob",
	})
	if err != nil {
		log.Fatal(err)
	}

	c := mastodon.NewClient(&mastodon.Config{
		Server:       "https://mstdn.jp",
		ClientID:     app.ClientID,
		ClientSecret: app.ClientSecret,
	})

	...
}

@178inaba
Copy link
Contributor Author

Thank you so much for merging!

@mattn
Copy link
Owner

mattn commented Apr 13, 2017

I was wondering where to place http.Client, but I put it in AppConfig.
Is this OK?

This is my expected.

@178inaba 178inaba deleted the application_registration branch April 13, 2017 15:34
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

Successfully merging this pull request may close these issues.

None yet

2 participants