Skip to content

Commit 9c55b7c

Browse files
committed
add more checks and a helper function to get the authentication token for the OAuth app
1 parent 3e8c4c4 commit 9c55b7c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

api/ruby/find-inactive-members/find_inactive_members.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,24 @@ def check_scopes
7171
end
7272

7373
def check_app
74-
info "Application client/secret? #{Octokit.client.application_authenticated?}"
74+
info "Application client/secret? #{Octokit.client.application_authenticated?}\n"
75+
info "Authentication Token? #{Octokit.client.token_authenticated?}\n"
76+
end
77+
78+
# helper to get an auth token for the OAuth application and a user
79+
def get_auth_token(login, password, otp)
80+
temp_client = Octokit::Client.new(login: login, password: password)
81+
res = temp_client.create_authorization(
82+
{
83+
:idempotent => true,
84+
:scopes => ["read:org", "read:user", "repo", "user:email"],
85+
:headers => {'X-GitHub-OTP' => otp}
86+
})
87+
res[:token]
7588
end
7689

7790
if options[:check]
91+
check_app
7892
check_scopes
7993
exit 0
8094
end

0 commit comments

Comments
 (0)