Codeigniter

구글 API를 통해서 배우는 인증 (oauth 2.0)

 

 

 

 

 

 

 

1. 사용자가 사이트(구글에서 인증 자원을 할당 받은 client)에 접속

 

2. 사용자가 사이트(구글에서 인증 자원을 할당 받은 client)에 접속 후 인증 
요청 Resource server 에 접속하기 위한 버튼 클릭.

ex)
버튼 클릭 주소  ex:
https://accounts.google.com/o/oauth2/v2/auth?
 scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&
 access_type=offline&
 include_granted_scopes=true&
 state=state_parameter_passthrough_value&
 redirect_uri=http%3A%2F%2Foauth2.example.com%2Fcallback&
 response_type=code&
 client_id=client_id

 


3. 사이트(구글에서 인증 자원을 할당 받은 client) 가 Resource Server(구글)

에 인증작업을 하러 가기.

 


4. Resource server(ex: 구글) 에서 scope List 즉 API 사용범위 


5. scope List 에 대한 code 를 client 요청


6. Resource server 에 전송


GET https://accounts.google.com/o/oauth2/v2/auth?
  scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file&
  state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&
  redirect_uri=https%3A%2F%2Fmyapp.example.com%2Fcallback&
  response_type=code&
  client_id=your_client_id&
  prompt=consent&
  include_granted_scopes=true

 

7. access token 발송

{
  "access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
  "expires_in":3920,
  "token_type":"Bearer"
}

 


8. Resource Server 에 API 사용

ex)calender 

 

https://console.developers.google.com/

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

It takes two to tango. (두 손뼉이 맞아야 소리가 난다.)

댓글 ( 4)

댓글 남기기

작성