Sha256: 2e5f4d3a53a2b18b6ddf518e649adf7b0f701dec5f4aeb6c8fde1eebc1e03ac3
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'dotenv/load' require 'webrick' require 'strava-ruby-client' server = WEBrick::HTTPServer.new(Port: 4242) trap 'INT' do server.shutdown end client = Strava::OAuth::Client.new( client_id: ENV.fetch('STRAVA_CLIENT_ID', nil), client_secret: ENV.fetch('STRAVA_CLIENT_SECRET', nil) ) server.mount_proc '/' do |req, res| code = req.query['code'] response = client.oauth_token(code: code) res.body = %( <html> <body> <ul> <li>token_type: #{response.token_type}</li> <li>refresh_token: #{response.refresh_token}</li> <li>access_token: #{response.access_token}</li> <li>expires_at: #{response.expires_at}</li> </ul> <body> </html> ) server.shutdown end redirect_url = client.authorize_url( redirect_uri: 'http://localhost:4242/', response_type: 'code', scope: 'read_all,activity:read,activity:read_all,profile:read_all,profile:write,activity:write' ) server.logger.info "opening browser at #{redirect_url}\n" system 'open', redirect_url server.start
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
strava-ruby-client-2.2.0 | bin/strava-oauth-token |
strava-ruby-client-2.1.0 | bin/strava-oauth-token |
strava-ruby-client-2.0.0 | bin/strava-oauth-token |