Masud Parves Bhuiyan
Masud Parves Bhuiyan

Reputation: 224

How to get Auth code Form github using a script?

To get Auth code from github I follow below process:

https://github.com/login?return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3Dea9c18f540323b0213d0%26redirect_uri%3Dhttp%253A%252F%252Fwww.example.com%252Foauth_callback%252F

Login page provided by github, and after logged in, it redirects to below site where the value of code changes it each time.

http://www.example.com/oauth_callback/?code=bf9beb5db17ea476fa46

I use value of '?code' query string as 'Auth Code'.

If there any way I could automate this process to get ?code value using application like curl? If it is possible, please give me some suggestion how to get this value.

Upvotes: 0

Views: 43

Answers (1)

Yuri Schimke
Yuri Schimke

Reputation: 13458

If you want to do it once, just generate a token once here https://github.com/settings/tokens

If you need to make this interactive for users, this is the auth flow in a Java based Mac OSX client. You could copy this approach, it redirects to a local webserver on localhost.

https://github.com/yschimke/oksocial/blob/master/src/main/java/com/baulsupp/oksocial/services/github/GithubAuthFlow.java

If you have macs (or linux with manual installation), you could use the client above https://github.com/yschimke/oksocial/wiki/Github

Upvotes: 1

Related Questions