README.md in usos_auth_lib-0.1.0 vs README.md in usos_auth_lib-0.1.1
- old
+ new
@@ -4,10 +4,29 @@
## USOS API
The USOS API, a cornerstone of academic data access, opens up a world of possibilities for developers seeking to integrate educational information into their applications. Following the OAuth 1.0a workflow as outlined in the official documentation from 'https://apps.usos.edu.pl/developers/api/authorization/', developers can securely implement user authentication and gain authorized access to the wealth of data stored in the USOS system.
The OAuth 1.0a workflow ensures a robust and secure authentication process, safeguarding user credentials while granting seamless access to the USOS API. By adhering to the guidelines provided in the official source, developers can confidently build applications that tap into the extensive educational resources offered by USOS, enriching their projects with academic data in a reliable and user-friendly manner. Explore the possibilities of educational integration through the USOS API and OAuth 1.0a, empowering your applications with a wealth of valuable information.
+
+## Installation
+Add this line to your application's Gemfile:
+
+```ruby
+gem "usos_auth_lib"
+```
+
+And then execute:
+```bash
+$ bundle
+```
+
+Or install it yourself as:
+```bash
+$ gem install usos_auth_lib
+```
+
+
## Usage
Here's an example for adding the configuration to a Rails app in `config/initializers/usos_auth_lib.rb`:
```ruby
UsosAuthLib.configure do |config|
config.api_key = "ENV.fetch('API_KEY', nil)"
@@ -43,47 +62,37 @@
user = User.create(
email: token[:email],
first_name: token[:first_name],
last_name: token[:last_name],
usos_id: token[:id],
- img_url: token[:photo_url] || nil
) unless user
user
end
end
```
Here's an example for callback method in `controllers/users_controller.rb`:
```ruby
-class UsersController < ApplicationController
- def usos_auth
- session[:access_token] = params[:token]
- session[:access_token_secret] = params[:secret]
- @user = User.from_usos(params)
+ def callback
+ user = User.from_usos(session.delete(:user_data))
+ session[:current_user_id] = user.id
end
-end
```
-Here's an example for use of handle_request method in `controllers/users_controller.rb`:
+Here's an example for use of handle_request and get_terms_grades method in `controllers/users_controller.rb`:
```ruby
class UsersController < ApplicationController
include UsosAuthCommon
- def usos_auth
- session[:access_token] = params[:token]
- session[:access_token_secret] = params[:secret]
- @user = User.from_usos(params)
- end
-
def grades
- response = handle_request(session[:access_token], session[:access_token_secret], '/services/grades/terms2?term_ids=2023/24Z')
+ response = handle_request(session[:access_token], session[:access_token_secret], '/services/grades/terms2?term_ids=2023/24Z|2022/23L')
- render json: response
+ response_2 = get_terms_grades(session[:access_token], session[:access_token_secret], '2023/24Z|2022/23L')
end
end
```
-In this example, we want to retrieve all grades from the 2023/2024Z semester.
+In this example, we want to retrieve all grades from the 2023/2024Z and 2022/2023L semester.
## Scopes
When you request a Request Token, you may pass the scopes parameter, which describes the things you want the User to share with you. Many API methods require you to have the access to multiple scopes.
When you ask a User to authorize your Request Token, USOS API will notify the User which scopes your application requires. Choose wisely - users may discard your request if you want too much!
@@ -118,26 +127,9 @@
- surveys_filling: Allows access to surveys from students point of view. With this scope you can fetch and fill out surveys.
- surveys_reports: Allows access to reports on surveys that concern user as a lecturer.
- theses_protocols_write: Allows access to editing diploma exam protocols, e.g. signing protocols.
Source: `https://apps.usos.edu.pl/developers/api/authorization/`
-
-## Installation
-Add this line to your application's Gemfile:
-
-```ruby
-gem "usos_auth_lib"
-```
-
-And then execute:
-```bash
-$ bundle
-```
-
-Or install it yourself as:
-```bash
-$ gem install usos_auth_lib
-```
## Contributing
Contribution directions go here.
## License