반응형
oauth2에 대한 다중 범위 값
일부 Google 서비스에 대한 내 응용 프로그램을 허용하기 위해 sereval 범위 값을 게시하려고합니다.
두 개의 입력 필드로 시도했습니다.
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
+ 구분 기호가있는 입력 필드 하나
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar+https://www.googleapis.com/auth/userinfo.email" />
하나의 범위로만 양식을 보낼 때 작동합니다. 그렇지 않으면 sereval 범위 값으로 Google 이이 오류 설명으로 나를 리디렉션합니다.
http://localhost:49972/redirect.aspx#error=invalid_request&error_description=OAuth+2+parameters+can+only+have+a+single+value:+scope&error_uri=http://code.google.com/apis/accounts/docs/OAuth2.html
oAuth2로 시작 하는 Google에서는 두 가지 범위 값으로 작동합니다.
내 코드는 다음과 같습니다.
<form id="form1" method="post" action="https://accounts.google.com/o/oauth2/auth?" >
<div>
<input type="hidden" name="response_type" value="code" />
<input type="hidden" name="client_id" value="my client id" />
<input type="hidden" name="redirect_uri" value="http://localhost:49972/redirect.aspx" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
<input type="hidden" name="state" value="/profile" />
<input type="submit" value="go" />
</div>
</form>
그것들을 하나의 필드로 결합했을 때 당신은 올바른 길을 가고있었습니다. 요청에는 공백으로 구분 된 값과 함께 하나의 범위 매개 변수 만 있어야합니다. 그런 형식으로 넣으면 브라우저가 공간 인코딩을 처리합니다.
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email" />
Steve Bazyl의 답변 외에도. 동일한 Google 서비스에 여러 범위를 적용 할 때 범위의 순서가 중요해 보입니다. Fe이 문자열은 예상대로 작동합니다.
"https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.metadata.readonly"
이것은 나를 위해 작동하지 않지만 :
"https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/drive"
그래도 문서에서 그것에 대한 정보를 찾지 못했습니다.
참조 URL : https://stackoverflow.com/questions/8449544/multiple-scope-values-to-oauth2
반응형
'IT이야기' 카테고리의 다른 글
C ++ 코드에서 Haskell 호출 (0) | 2021.03.30 |
---|---|
널 리터럴의 유형 (0) | 2021.03.30 |
프로그래밍 방식으로 사용자를 로그인 / 인증하는 방법 (0) | 2021.03.30 |
내 node.js 인스턴스가 개발 또는 프로덕션인지 확인 (0) | 2021.03.29 |
MemoryStream-닫힌 스트림에 액세스 할 수 없습니다. (0) | 2021.03.29 |