MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / parse_auth_fields

Function parse_auth_fields

aiscript-vm/src/builtins/sso.rs:51–113  ·  view source on GitHub ↗
(state: &mut State<'_>)

Source from the content-addressed store, hash-verified

49}
50
51fn parse_auth_fields(state: &mut State<'_>) -> Result<AuthFields, VmError> {
52 if let Value::Instance(receiver) = state.peek(0) {
53 let fields = &receiver.borrow().fields;
54 let client_id = fields
55 .get(&state.intern_static("client_id"))
56 .unwrap()
57 .as_string()
58 .unwrap()
59 .to_string();
60 let client_secret = fields
61 .get(&state.intern_static("client_secret"))
62 .unwrap()
63 .as_string()
64 .unwrap()
65 .to_string();
66 let auth_endpoint = fields
67 .get(&state.intern_static("auth_endpoint"))
68 .unwrap()
69 .as_string()
70 .unwrap()
71 .to_string();
72 let token_endpoint = fields
73 .get(&state.intern_static("token_endpoint"))
74 .unwrap()
75 .as_string()
76 .unwrap()
77 .to_string();
78 let userinfo_endpoint = fields
79 .get(&state.intern_static("userinfo_endpoint"))
80 .unwrap()
81 .as_string()
82 .unwrap()
83 .to_string();
84 let redirect_url = fields
85 .get(&state.intern_static("redirect_url"))
86 .unwrap()
87 .as_string()
88 .unwrap()
89 .to_string();
90 let scopes = fields
91 .get(&state.intern_static("scopes"))
92 .unwrap()
93 .as_array()
94 .unwrap()
95 .borrow()
96 .data
97 .iter()
98 .map(|scope| Scope::new(scope.as_string().unwrap().to_string()))
99 .collect::<Vec<_>>();
100
101 Ok(AuthFields {
102 client_id,
103 client_secret,
104 auth_endpoint,
105 token_endpoint,
106 userinfo_endpoint,
107 redirect_url,
108 scopes,

Callers 2

authority_urlFunction · 0.85
verifyFunction · 0.85

Calls 7

RuntimeErrorClass · 0.85
as_stringMethod · 0.80
as_arrayMethod · 0.80
peekMethod · 0.45
borrowMethod · 0.45
getMethod · 0.45
intern_staticMethod · 0.45

Tested by

no test coverage detected